selenium environment to build:

Environment to build

Based python3 and selenium3 do automated testing, saying: 工欲善其事必先利其器; there is no diamond do not embrace that porcelain live, may quicken the work, so you'll have to build a basic development environment, grasp the basic syntax and a python IDE for development, through here in detail, and describes how to build python3 selenium3 development environment, and provide a basic entry of the code, follow step by step provides a series of practical articles.

Installation package

python

I use python3.6.4, please select the corresponding version python The machine is 64-bit or 32-bit. (I believe that most people will be very calm to see the number of bits of their machines, not go into here, and if they can not clear Baidu click on it)

Python can go to the official website: https: //www.python.org/ downloading the installation package corresponding to the machine.

Download the installation package

The first step: enter the python's official website, click download, as shown below:

Step: Select the operating system and the corresponding python version, as shown below:

Step 3: Click to download python version, to download the package, as shown below:

 

development tools

Use the open source version pyCharm
https://download.jetbrains.com/python/pycharm-community-2017.3.2.exe

python installation process

The first step: Double-click the downloaded installation package python, the following interface appears, click Run

   

Then the following interface:

   

Here I chose the custom installation (Customize installation), be sure to check Add_Python 3.6 to PATH, prevent manually add environment variables, variables can be added to the environment, etc. Once installed manually added to the environment variable, if you do not add the environment the following interface will appear when the variable run python:

 

Here I did not choose to add environment variables, will hand back configuration

Continue to the next interface as follows:

 

选择安装的属性,Documentation、pip、tcl/tk and IDLE 必须安装,tcl/tk and IDLE是Python环境的开发环境窗口,pip用来安装numpy等package。 
我选择的是全部安装

继续下一步

ok了,点击install进行安装,在这里我安装的目录是D盘,D:\Python36  目录名可以自定义

注意我在这里依旧没有选择添加到环境变量,不想麻烦的话,可以直接选择添加到环境变量中

安装中

安装成功:

验证是否安装成功,使用系统的cmd命令:

验证失败,如果在安装的过程你选择了添加到环境变量中,输入python就会直接进入python的环境中,现在开始演示手动添加到环境变量:

首先,点击计算机->属性->高级系统设置

选择环境变量

新建 PATH 

 

点击确定,接下来进行验证python是否安装成功:

依然是cmd命令下输入python,效果如下:

当你输入python出现如下命令时则表示python环境已经安装好了,就可以进行python之旅了。

下载Selenium for python

1) 下载 Selenium for python

到 https://pypi.python.org/pypi/selenium#downloads 下载最新版本,当前是3.0.2

下载tar.gz的包

 

下载完解压:

 

2) 安装Selenium

打开cmd,然后cd到解压包当前路径,输入 python setup.py install ,cmd窗口会出现解压滚动屏幕,直到安装完成。如下图。

 

验证selenium安装成功办法:

      在cmd输入python进入python环境,然后输入 from selenium import webdriver,如果不报错就代表selenium安装成功。

 

3) 第二个安装selenium方式

还有一种安装方式,在线安装,在cmd输入 python -m pip install selenium,然后回车,自动安装。

小结

好了,还是那句老话,好多人都死在环境搭建的路上,幸运的你是否已经搭建成功。

Guess you like

Origin www.cnblogs.com/zhang-da/p/12046785.html