# coding = Utf-8%%%%%%%%%%%%%%%% prevent garbled (can be added without adding)
The From selenium import Webdriver%%%%%%%%%%%%%% uses the Webdriver function in selenium, so the Webdriver is directed in
Browser = Webdriver. The Firefox ()%%%%%%%%%%%%%%%%browser name is arbitrarily defined and used to manipulate functions. To control Firefox, you can switch to a different browser.
Browser.get ("http://www.baidu.com")%%%%%%%%%%%%%%%%%%%
browser.find_element_by_id ("kw"). Send_keys ("Selenium")%%% a control's property ID, name, (can also be located in other ways), Baidu input box ID is kw, I want to enter in the input box Selenium.
browser.find_element_by_id ("su"). Click ()%%%%%%%% the ID of the button to search is called Su, I need to click the button (click ())
Browser.quit ()%%%%%%%%%%% exit and close each associated driver of the window
There is one similar:
Browser.close ()%%% Close the current window
Add hibernation
Time.sleep (3) # sleeps 3 seconds
Where you want to sleep, add it.
See if it was executed
Print Driver.title # prints the page title
Automated testing first quarter-selenium + python (Environment Building and Basic code interpretation)