-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_2_1_DropDownList.py
More file actions
30 lines (24 loc) · 907 Bytes
/
2_2_1_DropDownList.py
File metadata and controls
30 lines (24 loc) · 907 Bytes
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
# -*- coding: windows-1251 -*-
from selenium import webdriver
import time
import math
from selenium.webdriver.support.ui import Select
try:
link = "http://suninjuly.github.io/selects1.html"
browser = webdriver.Chrome()
browser.get(link)
x = int(browser.find_element_by_css_selector("#num1").text)
x2 = int(browser.find_element_by_css_selector("#num2").text)
y = x + x2
#el = browser.find_element_by_css_selector("option[value='" + y + "']")
#el.click()
select = Select(browser.find_element_by_css_selector("#dropdown"))
select.select_by_value(str(y))
# Îòïðàâëÿåì çàïîëíåííóþ ôîðìó
button = browser.find_element_by_css_selector("button.btn")
button.click()
finally:
# îæèäàíèå ÷òîáû âèçóàëüíî îöåíèòü ðåçóëüòàòû ïðîõîæäåíèÿ ñêðèïòà
time.sleep(10)
# çàêðûâàåì áðàóçåð ïîñëå âñåõ ìàíèïóëÿöèé
browser.quit()