Selenium + Python automated test environment setup

Source: Internet
Author: User
Tags seleniumhq

Selenium is a web of automated testing tools, many learning function automation students began to prefer selenium, compared with QTP because it has a lot of a bit:

* Free, no need to crack QTP and big headache

* Small, for different languages it's just a package, and QTP needs to download and install 1 + G programs.

* This is also the most important point, whether you are more familiar with C, Java, Ruby, Python, or all C #, you can complete automated testing via selenium, while QTP only supports VBS

* Multi-platform support: Windows, Linux, MAC, multi-browser support: IE, FF, Safari, opera, Chrome

* Support the execution of distributed test cases, can distribute test cases to different test machine execution, equivalent to the function of the dispenser.

Installing Selenium

1. Install via PIP

c:\users\fnngj>python3-m pip Install Selenium

2. Install by download package

or download the Selenium package directly:

Https://pypi.python.org/pypi/selenium

Unzip, cmd into the directory:

c:\selenium\selenium2.53.5> python2.7 setup.py Install,

Try the results! Take the example on the Python website:

From selenium import webdriverfrom selenium.common.exceptions import Nosuchelementexceptionfrom Selenium.webdriver.common.keys import Keysimport timebrowser = Webdriver. Firefox () # Get Local Session of Firefoxbrowser.get ("http://www.yahoo.com") # Load Pageassert "Yahoo!" in Browser.titleele  m = Browser.find_element_by_name ("P") # Find the query Boxelem.send_keys ("SELENIUMHQ" + Keys.return) Time.sleep (0.2) # Let The page load, would be is added    to the Apitry: Browser.find_element_by_xpath ("//a[contains" (@href, '/HTTP// Seleniumhq.org ')] except nosuchelementexception:    assert 0, "can ' t find Seleniumhq" browser.close ()

Selenium + Python automated test environment setup

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.