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