Because of some confusion, so prepare to direct the project
Start learning a python web-driven test without thinking that it was wrong in the first place.
Environment is the latest version of Python,selenium,firefox,django, etc.
Tap the code on the book
From selenium import webdriver
browser = webdriver. Firefox ()
browser.get (' http://localhost:8000 ')
assert ' Django ' in Browser.title
Results no information wrong
Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py ", line, in Start Stdout=self.log_file, stderr=self.log_file) file"/usr/lib/python3.5/subprocess.py ", line 947, In __init__ restore_signals, start_new_session) File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_chil
D Raise Child_exception_type (Errno_num, err_msg) Filenotfounderror: [errno 2] No such file or directory: ' Geckodriver ' During handling of the above exception, another exception Occurred:traceback (most recent call last): File "Functi onal_test.py ", line 2, in <module> browser = Webdriver. Firefox () File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init __ Self.service.start () File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 81 , in Start Os.path.basename (Self.path), self.start_error_message) selenium.common.excePtions.
Webdriverexception:message: ' geckodriver ' executable needs to being in PATH. Exception ignored in: <bound method service.__del__ to <selenium.webdriver.firefox.service.service object at 0x7f3f272d3ac8>> Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/selenium/ webdriver/common/service.py ", line 173, in __del__ self.stop () File"/usr/local/lib/python3.5/dist-packages/selenium /webdriver/common/service.py ", line 145, in the stop if Self.process is None:
The key part is probably to say my what geckodriver all sorts of wrong
No paths were found and no path was added or anything
Baidu has found that a lot of people have this problem
Understand a bit about
Geckodriver is a Firefox driver.
But most of the online solutions are win.
StackOverflow a foreigner gave a solution to the downgrade, but the demotion is not always a good way, so continue to find
In general, the solution is to install Geckodriver on your own and add to the relevant path
So to GitHub (poke here) Download the Linux Geckodriver
Then do the related actions
sudo tar zxvf geckodriver-v0.11.1-linux64.tar.gz #解压
sudo mv geckodriver/usr/bin/#移动到指定路径
cd/usr/bin/ #进入路径
sudo chmod +x geckodriver #除去权限
After testing the Python code again, the success
A little cool, hey.
The solution comes from http://blog.csdn.net/heybob/article/details/52922645
Thank you, great God.