The construction of the Python Selenium test environment

Source: Internet
Author: User

Another fool tutorial, to prevent the learning of the little friends detours.

1.python Environment Construction

Python official website: https://www.python.org/downloads/Select the latest version of Python download

Python environment configuration: System variable in path add;D: \program Files\python;d:\program Files\python\scripts; (Path is the installation path for Python and script)

Enter Python in the run environment if the version information indicates that the environment variable is set successfully

2. Install Selenium via PIP

Enter PIP install selenium on the Python installation path to install selenium directly

Installation of 3.webdriver

Chromedriver (Chrome) or Geckodriver (Firefox) needs to be downloaded and stored in the Python path if prompted during the script run.

In the environment variable path also need to configure the Chrome browser environment variable C:\Program Files (x86) \google\chrome\application; (Path to Chrome's installation path)

After the installation is complete, the error is likely to be the version does not correspond to the problem, the following Web site provides the full chromedriver download and corresponding chrome version information: http://blog.csdn.net/huilan_same/article/details/51896672

Run a simple little script.

Python has its own compiler idle, path in "D:\Program files\python\pythonw.exe" "D:\Program files\python\lib\idlelib\idle.pyw"

Open the editor and enter the following code

# coding = Utf-8

From selenium import Webdriver

Driver = Webdriver. Chrome ()

Driver.get (' http://baidu.com ')

Print (Driver.title)

Driver.quit ()

Save, the default is the PY format file, save to the path where Python.exe.

You can run directly by double-clicking, or you can open the run with CMD, and you can view the print results

The construction of the Python Selenium test environment

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.