Recently, I am studying python+selenium for automated testing. Then the python development tool used is Pycharm. Then, today I will tell you how to build a complete set of automated testing environment.
install python
First, install python. python can be downloaded from the official website. Installation can refer to the link: http://blog.csdn.net/florachy/article/details/72769813
I have python 3.6.0 installed:
Configure environment variables
Generally, if the automatic creation of environment variables is checked during the installation process, we do not need additional manual configuration.
Configure environment variables, add python's C:\Program Files\Python36 directory to the system environment variable path, and you can use python directly under DOS commands.
If you add C:\Program Files\Python36\Scripts to the path, you can use pip directly in DOS commands. Otherwise, you have to go to this directory every time you install selenium and use pip.
install selenium
Browser Driver Placement
To start the browser through a script, you need to place the browser driver in the python installation directory, as shown in the following figure:
Install Pycharm
Reference link: http://blog.csdn.net/florachy/article/details/76647954
Pycharm configuration
When we enter "from selenium import webdriver" in Pycharm, we will find the following prompts:
We need to configure python's compiler. Select the directory where the correct python.exe is located. Click "Apply-OK".
Then you can write python scripts normally!
Script example
When running the above script, the following error is reported:
I found out later that it was because I changed the name of geckodriver.exe. So the browser driver should be properly prevented in the python directory like this: