Selenium+python Environment Construction

Source: Internet
Author: User

From graduation to now are engaged in functional testing work, functional testing for a long time, people will be more confused. have been thinking about self-taught automated testing, always think that as long as the learning LoadRunner or QTP This business-level tools will be automated testing, so busy for a while, the tool will use the basic or automated testing of laymen.

Unwilling to heart ah, go to the Big forum or blog, found cattle people do web automation testing with the Selenium+python,app automated test Appium. Then go to a variety of Web site search related information, in the mood of sharing to write down on the path of self-study, writing a bad place, please point out, we communicate with each other.

In order to facilitate their own review, will be installed on the Windows platform Selenium+python on the steps to write down, I also refer to the steps of the cattle people to share the experiment.

My Windows system is win 7,32 byte. I started my installation of Python 3.3, after the others said to install Python 2.7, so the 3.3 uninstall from the official website to download 2.7 of the package.

First, download python2.7,:http://www.python.org/getit from the website of Python, after downloading, click the. exe file to install it directly. Python installation is relatively straightforward. If your machine is 64byte, trouble selecting the appropriate installation package for installation.

Second, after the successful installation of python2.7, in order to avoid the subsequent problems, enter into the system environment variables, the path to install Python is written to path.

My python2.7 installation path is: C:\Python27

Right-click "My Computer", "Properties", "Advanced system Settings", "Advanced" tab, environment variables, "system variables", find path, edit, input; C:\Python27

When the environment variable is configured, OK, we go to the DOS command to execute python to see if Python is installed successfully. If it's the same as in my picture, the installation is OK.

Third, the Python is installed successfully, but we want to install selenium, this LZ is also very depressed, the online tutorial is installed selenium before installing Setuptools and Pip,lz is not particularly clear about the two things installed on what role, But do not install selenium can not be used, that first in accordance with the online tutorial first installed Bai, after figuring out again come to explain. Now that you want to install them, download the installation files for them first.

setuptools:Http://pypi.python.org/pypi/setuptools,LZ I said just entered this site is completely ignorant, all English, do not know where to click is to download this file, and then after my messy point, I found the link to the download. Forgive LZ English is not good.

Click BitBucket Repo link, will download a pypa-setuptools-acb8319982f1.tar.gz compressed file, Ok,setuptools This tool downloaded successfully, but not happy when oh, but also to download Pip Oh.

pip Download path : Https://pypi.python.org/pypi/pip,LZ said the pear is a bit big Ah, is an English, but LZ in the chaos Point still found the file package, to:

This time is to download a package called pip-7.1.0.tar.gz, OK, close to the success Oh, come on! Online tutorials have said download Selenium package, but LZ did not do so.

LZ suppressed the impulse of the heart just after hard to download the two package, the two extracted files into the root of the D-disk, of course, you can place any crossing, but LZ to you a small suggestion, put the path inside try not to have Chinese oh, otherwise, In fact, the LZ is not sure how the result is. But you can try and tell the LZ.

Ok,lz Setuptools Package path is: d:\pypa-setuptools,kg, you can open this folder to look inside the file, no EXE files, only py file, but I follow the online tutorial to find a ez_ install.py file, forgive LZ's eyes not good, I obstinately did not find. But how do you get this file in Setuptools? Give you a picture of the document, KG, you also help LZ look for.

Not urgent, let LZ slowly, we first into DOS, input CD D:\pypa-setuptools enter, LZ DOS command did not jump directly under this path, God horse situation ah, no way, I have entered a D:, this down into the D:\ Pypa-setuptools the path, come on, give you a picture to see.

Since there is no ez_install.py file in the folder, what should I do? LZ is also quite depressed, why LZ downloaded the file there is no ez_install.py this file? Without this file, the LZ is going to execute that file? LZ just beginning also quite tangled this problem, later also don't want to, directly in the DOS window input Python setup.py install Enter, do not know is not LZ luck good or other reason, this setuptools installs well, LZ are fast happy to cry.

Setuptools installation is successful, OK, the next step to install the PIP,PIP package path is: D:\pip-7.1.0, also in the DOS command window into the D:\pip-7.1.0,python setup.py install Enter, PIP also completed the installation , did you feel like a little bull X in here? However, we do not hurry to be happy, PIP has not been fully installed, oh, in the DOS window into the c:\python27\scripts, enter the success, enter the Easy_install pip, this pip is only counted installation completed.

Finally, there is a selenium to install, after the installation of selenium is finished oh. Install selenium time, must be in the state of the Internet, oh, do not let the words will not be successful OH.

Say less nonsense, and we begin.

or in the DOS command window, enter C:\Python27\Scripts, enter the success, input Pip Install-u Selenium,lz again, must be networked oh, do not let selenium download unsuccessful Oh. In the networked state, the input pip install-u Selenium will automatically download selenium.

Come here to our selenium+python environment is done, in order to facilitate the code, LZ downloaded a pycharm tool, so that you do not have to pyhon idle inside the code, pycharm tools when you hit the code will automatically associate with the command you want, Does it feel more convenient?

OK, let's use a small piece of code to verify the Selenium+python environment.

# Coding =utf-8from Selenium import webdriverdriver=webdriver. Firefox () #调用火狐浏览器driver. Get ("http://www.baidu.com") #输入baidu地址print driver.title# print out the title Information Driver.quit () #退出浏览器

  

Selenium+python Environment Construction

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.