Selenium environment Build-python automated script test

Source: Internet
Author: User
Tags python script run python script

Stand on the shoulders of friends to learn!!!

Prerequisite: The python environment has been built

1. Installing Selenium

Command line Input "pip install Selenium" one-click Installation

2. Check if the selenium is installed successfully

Use the command "Pip show Selenium" to see the version information that is installed on the current system

3. Successful installation, can run Python script

Expected to reach: Open the Firefox browser, enter the Baidu URL, open the Baidu interface, in the Baidu search box, enter the "Selenium2" keyword, then click "Baidu" button search results, and then automatically close the browser

Post code:

Note: If the run fails, the browser cannot be opened and an error message is returned

This is because the Firefox browser has updated the new engine in the new version. Previous versions of Firefox were using Google's native drivers,

At that time, Google's native driver supported the Firefox engine, but now Firefox updated the engine, and Google's native driver did not do the corresponding update, so the above problems arise,

WORKAROUND: You will need to re-download a driver file named "Geckodriver.exe", and after downloading its path is configured in the PATH variable. or copy the file directly to the Python installation directory

Download path for Geckodriver.exe: https://github.com/mozilla/geckodriver/releases

Re-run, you can implement the code!!!!

Into the pit one: Forget the python installation path

Workaround: Open Our cmd command to enter Python, enter the import sys, and enter the fourth in the print (Sys.path) list will be your installation path

Into the pit two: the computer can not find the path found,

Maybe the file is hidden.

FIX: Hidden folders are displayed under Win7:

Selenium environment Build-python automated script test

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.