The use of selenium framework

selenium is a browser test automation framework can be directly installed before use pip install selenium

You need to select the currently used driver download invoke the browser to match. The adopted version of Chrome 74, Chrome driver download address: http://chromedriver.storage.googleapis.com/index.html

Use small case:

from Selenium Import the webdriver
 from Time Import SLEEP 

Bower = webdriver.Chrome (R & lt executable_path = ' C: \ the Users \ asaxh \ Desktop \ chromedriver.exe ' ) 

bower.get (URL = ' https://www.hao123.com/ ' )         # Specifies the navigation bar the URL of 
SLEEP (2 ) 

TEXT_INPUT = bower.find_element_by_name ( ' Word ' ) 
text_input.send_keys ( ' Hu Ge ' )                      # to search the content of elements 
SLEEP (2 )

bower.find_element_by_class_name ( ' submitInput ' ) .click () # click on the search elements 
SLEEP (3 ) 

bower.quit ()         # close the browser and exits

 

Guess you like

Origin www.cnblogs.com/wen-kang/p/10954647.html