-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask7.py
More file actions
51 lines (38 loc) · 1.62 KB
/
task7.py
File metadata and controls
51 lines (38 loc) · 1.62 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
42
43
44
45
46
47
48
49
50
51
import select
import time
from helper.driver import web_driver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import math
from selenium.webdriver.support.ui import Select
browser = web_driver().driver_init()
link = "http://suninjuly.github.io/execute_script.html"
# select.select_by_visible_text("text") и select.select_by_index(index)
def calc(x):
return str(math.log(abs(12*math.sin(x))))
def test(link):
try:
browser.get(link)
x = browser.find_element(By.ID, 'input_value').text
y = calc(int(x))
inp = browser.find_element(By.ID, "answer")
browser.execute_script("return arguments[0].scrollIntoView(true);", inp)
inp.send_keys(y)
chekbox = browser.find_element(By.XPATH, '//label[@for="robotCheckbox"]')
browser.execute_script("return arguments[0].scrollIntoView(true);", chekbox)
chekbox.click()
chekbox2 = browser.find_element(By.XPATH, '//label[@for="robotsRule"]')
browser.execute_script("return arguments[0].scrollIntoView(true);", chekbox2)
chekbox2.click()
button = browser.find_element_by_tag_name("button")
browser.execute_script("return arguments[0].scrollIntoView(true);", button)
button.click()
finally:
# ожидание чтобы визуально оценить результаты прохождения скрипта
time.sleep(10)
if __name__ == "__main__":
try:
test(link)
finally:
# закрываем браузер после всех манипуляций
browser.quit()