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