-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_4_2_wait4Text_OnPage.py
More file actions
41 lines (31 loc) · 1.21 KB
/
2_4_2_wait4Text_OnPage.py
File metadata and controls
41 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: windows-1251 -*-
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
import time
import math
from selenium.webdriver.support.ui import Select
def calc(x):
return str(math.log(abs(12*math.sin(int(x)))))
try:
link = "http://suninjuly.github.io/explicit_wait2.html"
browser = webdriver.Chrome()
browser.get(link)
# ãîâîðèì Selenium ïðîâåðÿòü â òå÷åíèå 12 ñåêóíä, ïîêà òåêñò íå ñòàíåò ðàâíûì 100
button = WebDriverWait(browser, 12).until(
EC.text_to_be_present_in_element((By.ID, "price"), "$100")
)
button = browser.find_element_by_css_selector("#book")
button.click()
x = browser.find_element_by_css_selector("#input_value").text
y = calc(x)
browser.find_element_by_css_selector("#answer").send_keys(y)
# Îòïðàâëÿåì çàïîëíåííóþ ôîðìó
button = browser.find_element_by_css_selector("#solve")
button.click()
finally:
# îæèäàíèå ÷òîáû âèçóàëüíî îöåíèòü ðåçóëüòàòû ïðîõîæäåíèÿ ñêðèïòà
time.sleep(10)
# çàêðûâàåì áðàóçåð ïîñëå âñåõ ìàíèïóëÿöèé
browser.quit()