?下拉框选值问题
#下拉框选值问题
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
driver = webdriver.Chrome()
driver.get('http://sahitest.com/demo/selectTest.htm')
select = Select(driver.find_element_by_id("s4Id"))
time.sleep(1)
select.select_by_value("o4val")
time.sleep(3)
options2 = select.all_selected_options
print('查看下拉选项中所有值为"o4val"的选项')
for selected in options2:
print(selected.text)
options = select.options
print("查看所有选项")
for allSelect in options:
print(allSelect.text)
select.deselect_all()
|