-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask5.py
More file actions
43 lines (31 loc) · 1.21 KB
/
task5.py
File metadata and controls
43 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
42
43
import time
from helper.driver import web_driver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import math
browser = web_driver().driver_init()
link = "https://suninjuly.github.io/math.html"
link2 = "http://suninjuly.github.io/registration2.html"
def calc(x):
return str(math.log(abs(12*math.sin(int(x)))))
def test(link):
try:
browser.get(link)
x_text = browser.find_element(By.ID, 'input_value').text
y =calc(x_text)
y_input = browser.find_element(By.ID, 'answer')
y_input.send_keys(f'{y}')
chekbox = browser.find_element(By.XPATH, '//label[@for="robotCheckbox"]')
chekbox.click()
chekbox2 = browser.find_element(By.XPATH, '//label[@for="robotsRule"]').click()
button = browser.find_element(By.CSS_SELECTOR, "button.btn")
button.click()
finally:
# ожидание чтобы визуально оценить результаты прохождения скрипта
time.sleep(10)
if __name__ == "__main__":
try:
test(link)
finally:
# закрываем браузер после всех манипуляций
browser.quit()