Automated testing first quarter-selenium + python (Environment Building and Basic code interpretation)

Source: Internet
Author: User

# 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.