-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_6_2_Math_n_FillTheForm.py
More file actions
36 lines (28 loc) · 1.01 KB
/
1_6_2_Math_n_FillTheForm.py
File metadata and controls
36 lines (28 loc) · 1.01 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
# -*- coding: windows-1251 -*-
from selenium import webdriver
import time
import math
url = "http://suninjuly.github.io/find_link_text"
try:
linktext = str(math.ceil(math.pow(math.pi, math.e) * 10000))
browser = webdriver.Chrome()
browser.get(url)
link = browser.find_element_by_partial_link_text(linktext)
link.click()
#time.sleep(5)
input1 = browser.find_element_by_tag_name("input[name='first_name']")
input1.send_keys("Ivan")
input2 = browser.find_element_by_name("last_name")
input2.send_keys("Petrov")
input3 = browser.find_element_by_class_name("city")
input3.send_keys("Smolensk")
input4 = browser.find_element_by_id("country")
input4.send_keys("Russia")
button = browser.find_element_by_css_selector("button.btn")
button.click()
finally:
# óñïåâàåì ñêîïèðîâàòü êîä çà 30 ñåêóíä
time.sleep(30)
# çàêðûâàåì áðàóçåð ïîñëå âñåõ ìàíèïóëÿöèé
browser.quit()
# íå çàáûâàåì îñòàâèòü ïóñòóþ ñòðîêó â êîíöå ôàéëà