Home > other >  Selenium positioning drop-down box, to baidu's operating set as an example
Selenium positioning drop-down box, to baidu's operating set as an example

Time:09-26

Mainly introduces the use of the select methods
Specific code below

# conding=utf-8
The from the selenium import webdriver
The from selenium.webdriver.com mon. Action_chains import ActionChains
The import time
The from the selenium. Webdriver. Support. Select the import the select

Driver=webdriver. Chrome ()
Driver. Maximize_window ()
Driver. The get (" http://www.baidu.com ")
Time. Sleep (1)
Mouse=driver. Find_element_by_link_text (" set ")
ActionChains (driver). Move_to_element (mouse). The perform ()
Driver. Find_element_by_link_text (" search Settings "). Click ()
Time. Sleep (2)
m=driver find_element_by_id (" nr ")
Select (m) select_by_index (" 1 ")

Time. Sleep (1)

Driver. Find_element_by_link_text (u "save Settings"). Click ()
Time. Sleep (1)
Driver. Switch_to. Alert. The accept ()







driver.quit()
  • Related