Selenium+python Environment Construction (under Windows)

Source: Internet
Author: User

First, download the relevant installation packages and tools

1. Download python

Address: https://www.python.org/downloads/

Description: Recommended download 2. x version, can be understood under about 2. The difference between x and 3.X.

2. Download Python installation package management tool PIP

Address: Https://pypi.python.org/pypi/pip

Description: The file name is pip-version number. tar.gz (MD5, PGP)

3. Download Python Basic Package tool Setuptools

Address: Https://pypi.python.org/pypi/setuptools

Note: File two compression format can be, file name setuptools-version number. zip (MD5)

4. Download Selenium installation package

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

Description: File name selenium-version number. tar.gz (MD5)

Second, the Environment configuration

1. Install Python

Double-click the MSI installation package that runs the downloaded Python for Windows

Attention:

When selecting a step in the installation component, tick the last component: Add Python.exe to Path, if not checked during installation, add to the system environment variable Path.

Test:

Open cmd, enter a python return, check whether the Python version of the relevant content, pop-up indicates that the installation configuration is successful.

2. Install Pip

Unzip the downloaded Pip,cmd window to enter the extracted directory and use the command to install:

E:\user\learn\pip-8.1.1>python setup.py Install

When done, enter C:\Python27\Scripts:

C:\python27\scripts>easy_install pip

Attention:

CMD in open after default to C drive, switch to e-drive:

E: Enter

To switch to the directory:

CD E:\user\Learn\pip-8.1.1 Enter

3, Installation Setuptools

Unzip the downloaded installation package, and then use the command to install the CMD window after it enters the extracted directory:

E:\user\learn\setuptools-21.0.0>python setup.py Install

4, installation Selenium

Method One:

Online Installation: Enter the installation directory where PIP is installed and perform the command installation:

C:\python27\scripts>pip Install-u Selenium

Method Two:

Offline Installation: Unzip the downloaded installation package to the C:\Python27\Lib\site-packages directory

Third, test whether to build success

1. Writing scripts

New Script test.py, enter the following ice Save:

#coding: Utf-8
From selenium import Webdriver

Driver = Webdriver. Firefox ()
Driver.get ("https://www.baidu.com")

2. Run the script

In the cmd window, switch to the directory where the test.py is located and run:

Python test.py

Check whether to start Firefox and open Baidu homepage. If it is already open, the installation is successful!

Selenium+python Environment Construction (under Windows)

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.