Win7x64 Position Seleniume+eclipse+pydev Environment construction

Source: Internet
Author: User

1. Download, install 64-bit JDK and set environment variables


: http://www.cr173.com/soft/2457.html and installenvironment variable settings (computer-Properties-Advanced system settings):1) Increase Java_home:c:\program files\java\jdk1.6.0_432) Increase Classpath:c:\program Files\java\jdk1.6.0_43\lib\dt.jar; C:\Program Files\java\jdk1.6.0_43\lib\tools.jar3) Append Path:c:\program files\java\jdk1.6.0_43\bin;cmd: input java and Javac Verify the correctness of installation and configuration 2. Download Python : http://python.org/getit/and installenvironment variable settings: My Computer, properties, advanced-environment variable--the path in the system variable is: C:\Python27cmd: Enter Python to verify installation and configuration correctness 3, download Setuptools "In fact, Setuptools is a tool to help you install third-party toolkit software"

Win7 64 bits must be installed using the ez_setup.py. By downloading ez_setup.py, the Python ez_setup.py is executed under CMD to automatically install the Setuptools. There are currently no direct EXE installation versions.

code: http://peak.telecommunity.com/dist/ez_setup.py, copy the code on the page to a TXT file, modify the name to ez_setup.py, and then enter Python in the DOS window ez_ setup.py Automatically downloads and installs (requires networking), the Scripts folder is generated in C:\Python27 when the installation is complete, and the section is installed in the Lib folder.  remark:32-bit operating system: http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe#md5= 57e1e64f6b7c7f1d2eddfc9746bbaf20, download exe directly after installation.  4. Install PIP method One) install using the Setuptools installed in the second step, open the DOS interface and go to the directory:C:\Python27\Scripts, then typing the command: easy_install Pip, wait for the completion to be OKthe installation failed with this method, the corresponding PIP version is recorded in the error prompt, and then the version is found and downloaded and then installed by the command: Method two.  method Two) download PIP for installation:https://pypi.python.org/pypi/pip#downloads (select 1.5.2 version, unzip after download) cmd to unzip the address and execute the command: after decompression, use the cmd command: Python setup.py install (if the Python command is unsuccessful, configure the environment variable under Python.) Open the cmd command and enter the Python scripts directory (such as c:\python27\scripts) and enter Easy_install PIP.  5, installation Selenium : Http://pypi.python.org/pypi/seleniumconnected directly using PIP installation, command into the Python scripts directory, execute: Pip install-u Selenium (the author uses this method to install);If there is no Internet connection, unzip the selenium-2.28.0.tar.gz. Selenium the entire folder into the Python27\lib\site-packages directory (not validated).  

6. Verify Selenium installation is successful

Write the following code in Notepad: (Save as pytest.py, then double-click to run directly!) )

From selenium import Webdriver

Browser = Webdriver. Firefox ()

Browser.get ("http://www.baidu.com")

Browser.close ()

Successful operation indicates successful installation

7, Python development environment Configuration-eclipse-pydev plug-in installation

Two installation methods for installing the Pydev plug-in:

1) Baidu search Pydev 2.4.0.zip, after download decompression, get plugins and Feature folder, copy two folders to eclipse directory, cover can. "I install time download version is Pydev 2.7.4, after downloading the corresponding folder files copied to eclipse corresponding folder"

When you are done restarting eclipse, if you see the Pydev component in the Eclipse menu Help->about eclipse->installation detail->plug-ins, the installation is successful.

2) Select the menu directly in Eclipse: Help-install New software. -add, enter http://pydev.org/updates, download and install.

8, Configuration PyDev

After installing the PyDev, the Python/jython interpreter needs to be configured and the configuration process is simple.

In the Eclipse menu bar, choose Window > Preferences > Pydev > Interpreter-python, where you configure the python/interpreter to add the installed interpreter. Here, Python is installed under the C:\Python27 path. Click New, select the Python interpreter python.exe, open a window with many checkboxes, select the path you want to add to the system PYTHONPATH, and click Ok.

9. Execute Selenium Instance

Next, let's create a Python project.

In the Eclipse menu bar, choose File > New > Project > Pydev > Pydev Project, New project: Pythoncase, click Next.

Complete the following:

Creating Python Packages and modules

Next, start creating Python packages and modules in the project you just created.

Enter the Pydev perspective, in the Python package Explorer, right-click SRC, select New->pydev Package, and enter the package name Python27.

When you click the Finish,python package, it is created, and the __init__.py file is automatically generated, and the file contains no content.

Attention:

If the Create default SRC folder and add it to the Pythonpath check box is not selected when creating the project, you need to pass File > New > Other > Source Folde R manually create a source code folder src.

After you have created the Pydev package, right-click the packages you created, select New->pydev module, and enter the module name Pythoncase1.pyfinish. In this way, the Python module is built.

Modify the pythoncase1.py content as follows:

#-*-Conding=utf-8-*-

From selenium import Webdriver

if __name__ = = "__main__":

Driver = Webdriver. Firefox ()

Driver.implicitly_wait (30)

Driver.get ("http://www.google.com.hk")

Driver.find_element_by_name ("Q"). Send_keys ("Hello selenium!")

Driver.find_element_by_name ("Q"). Submit ()

Print ' Page title is: ', Driver.title

Driver.quit ()

Execute script

Run Run_selenium.bat and start the Selenium RC server. Right-click Pythoncase1.py,run As->python Run to perform the following successful results:

Win7x64 Position Seleniume+eclipse+pydev Environment construction

Related Article

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.