In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Selenium is an automated testing tool for web, and many students with automated learning functions begin to choose selenium because it has many points compared with QTP:
* it's free, and you don't have to worry about cracking QTP.
* small, it's just a package for different languages, and QTP needs to download and install a multi-gigabyte program.
* this is also the most important point. Whether you are more familiar with C, java, ruby, python, or all C #, you can do automated testing through selenium, while QTP only supports VBS.
* support for multiple platforms: windows, linux, MAC, and multiple browsers: ie, ff, safari, opera, chrome
* support the execution of distributed test cases, which can be distributed to different test machines for execution, which is equivalent to the function of a distributor.
With regard to the combination of the basic knowledge of selenium and the java platform, I have previously written a series of "Rookie Learning Automation testing" and recently learned python, so I would like to try how to build selenium on the python platform; fortunately, the article on this method is very easy, and I will organize and share the building steps here.
Build a platform windows
The preparation tools are as follows:
Download python
Https://www.python.org/
If you are a newcomer to python, you have to rely on pyhton2.x for packages you do not want to use, then please do not hesitate to choose python3.5!
Window installation steps:
1. Download the python installation.
Https://www.python.org/downloads/release/python-351/
Choose the corresponding version according to your operating system 32max 64-bit.
I don't need to describe the installation process. My installation directory is: C:\ Python35
2. Enter the "python" command under cmd (windows command prompt).
If prompted that python is not an internal or external command! Don't worry, go and configure the environment variables.
Modify the PATH in my computer-> Properties-> Advanced-> Environment variables-> system variables to:
Variable name: PATH
Variable value:; C:\ Python35;C:\ Python35\ Scripts
3. Install selenium
3.1. install through pip
C:\ Users\ fnngj > python3-m pip install selenium
3.2. Install by downloading the package
Or download the selenium package directly:
Https://pypi.python.org/pypi/selenium
Decompress and enter cmd into the directory:
C:\ selenium\ selenium2.53.5 > python3 setup.py install
=
Installation method under ubuntu:
1. Install: setuptools
Root@fnngj-H24X:~# apt-get install python-setuptools
2. Install pip
Root@fnngj-H24X:/home/fnngj/python# tar-zxvf pip-1.4.1.tar.gz
Root@fnngj-H24X:/home/fnngj/python# cd pip-1.4.1/
Root@fnngj-H24X:/home/fnngj/python# python setup.py install
3. Install selenium
Root@fnngj-H24X:/home/fnngj/python/pip-1.4.1# pip install-U selenium
Congratulations! Your preliminary work has been done, the above steps are indeed a little tedious, but not difficult, but we have completed it, let's experience 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.titleelem = browser.find_element_by_name ("p") # Find the query boxelem.send_keys ("seleniumhq" + Keys.RETURN) time.sleep (0.2) # Let the page load, will be 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 ())
(if an error occurs during the run:
WebDriverException: Message: u'Unexpected error launching Internet Explorer.
Protected Mode settings are not the same for all zones. Enable Protected Mo
De must be set to the same value (enabled or disabled) for all zones.'
Change the internet option of IE-> Security to uncheck or check all the enabled protection modes in the Internet/ local Internet/ trusted site / restricted site. )
-
A good document for selenium + python
Http://selenium.googlecode.com/git/docs/api/py/index.html
= if you want to run the script through another browser (IE Chrome) = =
Install Chrome driver
The download address of chrome driver is here.
1. Download and decompress, and you will get a chromedriver.exe file (I click on it and run the prompt started no prot 9515, what is this for? Port 9515 is occupied? After messing around for a long time, I later learned that I needed to put this guy in the chrome installation directory.\ Google\ Chrome\ Application\, then set the path environment variable, change the chrome installation directory (my:\ Program Files\ Google\ Chrome\ Application), and then call to run:
# coding = utf-8from selenium import webdriverdriver = webdriver.Chrome () driver.get ('http://radar.kuaibo.com')print driver.titledriver.quit ()
Another mistake was reported:
Chrome version must be > = 27.0.1453.0\ n (Driver info: chromedriver=2.0,platform=Windows NT 5.1 SP3 x86)
It is said that the version of my chrome is not greater than 27.0.1453.0, this is easy, just update to the latest version.
Install IE driver
In the new version of webdriver, only ie driver is installed for testing with ie.
The download address of ie driver is here. Remember to download the corresponding driver according to the operating system version of your machine.
I haven't tried it yet, it should be similar to the way chrome is installed.
Remember to configure the protection mode of IE
If you want to start IE using webdriver, you need to configure the protected mode of IE.
Just select or tick off all the protection modes in IE.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.