Python+selenium Environment Construction

Source: Internet
Author: User

first, Download the relevant software

1.python

http://python.org/getit/

2.setuptools

Http://pypi.python.org/pypi/setuptools

3.pip

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

second, Installation and verification

1. Install Python

Python directly click on the application to run, the default installation in C:\Python27, after installation, you need to add C:\Python27 in the environment variable path of the system;

Verify that Python is installed successfully, open cmd, and then enter python--version at the command line. If you look at Python 2.7.9, it means that the installation and configuration of Python is successful;

So you can write a Python program. Open your own Idil (Python GUI) and write ' hello,world! ‘;

2. Installing Setuptools

Unzip the downloaded Setuptools and put it in the C:\pythoon27 folder.

Execute the following command in Cmd: C:\Python27\setuptools-28.7.1>python setup.py install;

After installing the setuptools, you can see the script directory under the PYTHON27 installation directory, then you need to add C:\Python27\Scripts this directory to the system Environment.

3. Install PIP

Unzip the downloaded PIP into the c:\python27 folder.

execute the following command in Cmd: C:\python27\pip-8.1.2>python setup.py install;

verify Pip and execute the following command in Cmd: C:\python27\scripts>pip

4. Installing Selenium

CMD execution command: c:\python27\scripts>pip install selenium;

Verify that the installation is Successful. Enter the Scripts directory and enter the following command:C:\python27\scripts>pip show Selenium ;

5. python+selenium, Run the automation script

Open the idle (python GUI) > File>new File

Enter the following code, save as test.py file, and click Run>run Module to Run. (prerequisite: Firefox installed)

#coding =utf-8
From selenium import Webdriver
Driver = Webdriver. Firefox ()
Driver.get ("http://www.baidu.com")
driver.find_element_by_id ("kw"). Send_keys ("testing")
driver.find_element_by_id ("su"). Click ()
Driver.quit ()

Python+selenium 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.