Python+selenium Installation

Source: Internet
Author: User

1. Download python

please download and install https://www.python.org/downloads/on the website .

When installing, be sure to tick this option to avoid the hassle of configuring system variables.

  

Select the second installation method, remember to select Pip, which is the shortcut to install Selenium

  

The next step of the "installation Location", Xiao Jin recommended not to install to the C drive, you know.

Finally, use the command line that Xiao Jin worships most to see if our installation is successful.

Open the command line and enter python

Here we can see the version number and go directly to the Python edit mode.

Enter here python the Code

For example: Calculate 3+2,print in Python3 need Add () can oh, otherwise will error.

Enter exit () to exit python edit mode

  2. Installing Selenium 

Here is the use of what we have just said in the installation, be sure to hook up, Pip.

Open the command line and enter python-m pip install Selenium

  

Note, please, do not wait until the installation is completed 100% is at ease, if not successful, more than a few times this command is good.

3. Download Driver

  It is said that, in Selenium1 and 2, a long time ago, the driver was embedded inside, however, the selenium3 used by the small series need to be manually configured to drive. It's okay, the Who's Afraid of who?!.

The next step is to give a brief explanation of the Firefox driver installation configuration as an example.

Open URL:https://github.com/mozilla/geckodriver/releases, select a version of the driver to download. Here to illustrate, sometimes when running the program will appear, open browser, but can not open the situation of the development of Web pages, it is likely that because your browser version and driver version is not compatible, please change the driver version, try again. The mini-series uses Firefox 52.3 version and V0.16.0

Next, we're going to unzip the downloaded drive put in Firefox in the installation directory

  

Next, we want to configure environment variables for the drive.

Right-click on "My Computer" and select "Properties" to open the path variable in the order of the diagram, in the path environment variable, add the driver's "path" path, each driver is installed, Need to add a path like this.

  

in particular, the use of Internet Explorer , we also need to configure the IE browser protection mode, or the browser will still not be enabled.

Open IE Browser, select "Tools ->internet Options" in the menu bar, Open the tab, tick or uncheck "Enable protected mode" for these four items, click OK

  

4. Open a browser

  Finally to the last step, we open a notepad, named test.py. Enter the following code in the document:

  

To add, at the very beginning, without the use of large, professional Python programming software, we still have to exercise the ability to tap code. Installing a notepad++ is a good choice. At the same time, right-click on the python file that we have already written, and we can find the IDE that comes with it, as shown in.

If you want to run this software using Notepad or notepad++, we can use the command line.

Open the command line, locate the directory where the files are located, and enter Python xxx.py to run

If you are in the IDE above, just press F5 to run the program

  

Figures 1 and 2 are windows that are automatically opened for us, and 1 are similar to the Eclipse console, where you can print some output information, log logs, and 2 drivers for Firefox.

If you can successfully open Firefox and visit Baidu, it is a successful

Python+selenium Installation

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.