Installing Python+selenium
Blogging is a good choice, first of all, is to worry about their own forgotten, second, you can make a reference:
In fact, this is their first time to build a Python environment (before the use of a week of idle), or relatively easy to do it;
Encounter problems, basically Baidu can find a solution;
The main thing is to thank the "pest Division" sharing http://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html
1. First, since we need selenium+python, we need to download Python
https://www.python.org/
Here I as Python small white, direct use is Python3, times in progress, believe that the new version more in line with our needs!
My is Windows system, so directly find download under the Windows download Python3.6.4
https://www.python.org/downloads/windows/
2. Before watching the video above, the teacher installed after the python, will be in DOS under the verification of a, decisive input: "Python" verified a bit (and sure enough)
Find the worm's way, configure the environment variables
Configure path:; C:\Python35; C:\Python35\Scripts; (Here for beginners 1. Do not forget that multiple variable values are separated by a ";" number; 2. Do not delete the value of a variable that has existed before (some people did, I don't say ~_~!))
This time, go to cmd, "Python" is duly displayed
3. Download and install Selenium 3.8.0
Give you an address, you know. There are some English introduction, how to install and simple to use, I did not install pip directly find download, download selenium-3.8.0.tar.gz
Https://pypi.python.org/pypi/selenium
Then, follow the method described above, install Python setup.py install
Madan, again error, hint of what forget, but there is the keyword "setuptools", Baidu for a reason, not installed Setuptools
At this point, Python and selenium are basically installed!
Eclipse+python
There are a lot of ways to use Python on the web, but I used eclipse before, so I want to write code in eclipse with Python:
This place is heard that there are 2 ways to install
1.Python in eclipse has a plug-in called Pydev 2.4.0.zip, directly download the installation, download, unzip, get Plugins and Feature folder, copy two folders to Eclipse directory, overwriting can be.
This method I did not use, I used the testng, directly from eclipse to download plug-ins, so I also used the more familiar with the second method
2. Similar to testng, select directly from the Eclipse menu
Help-->install New software...-->add--> name Pickup
The address is:http://pydev.org/updates,
After the installation is successful, you need to configure the Python interpreter
Just follow the procedure below:
Find Window-->preferences-->pydev-->interpreters-->python interpreter in Eclipse and Python.exe new to Python Interpreter inside, the appearance of libraries all imported;
Once you're done, you can create a new project.
Then, you will find that after the new project, there will be a variety of problems,
1. New project: Same as Java
2. Add module, equivalent to the class in Java
Then, I do Web automation, of course, I want to open a browser to try it, we all know selenium more support Firefox, so I wrote a bit of code
From selenium import Webdriver
Driver = Webdriver.firefox ()
Direct execution, OMG no matter how many times you run, it will prompt you, ' geckodriver ' executable needs to is in PATH.
This is what ghosts, I do not know, but the magic of the network there are many ways to solve it;
Downloaded a geckodriver:https://github.com/mozilla/geckodriver/releases (I don't know if I can open it later, but it's not smooth when I open it)
After that, configure the environment variables in path, as described in how to configure
But, after all this, it's still not working,unable to find a matching set of capabilities
This is what ghost, you are sent to play tricks on me,,, do not know to ask Baidu----no problem
Open Firefox, update him a wave, directly from the 43.xx version of the update to 56.XX
Fix the problem properly;
Then the same way to try Chrome, (our project supports chrome), no problem, this can be a safe blog to write a day to record the learning
I hope not to die in the path of Python, we need to find the cause of the problem, timely resolution, or the problem piled up too much, we may take a shortcut: "Python get started to give up"
The first time to write such a long blog, ~_~! Share!!!
Summary of building Selenium + python environment: