标签:cut space style rck init driver 执行 tab mos
从selenium3开始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而之前是executable_path="wires"。所有需要下载geckodriver。
1、下载 geckodriverckod 地址: https://github.com/mozilla/geckodriver/releases
2、解压后将geckodriverckod可以存放在任意路径,在使用webdriver时指明路径就行。
例如:
将geckodriverckod放在/usr/local/bin/下,
driver = webdriver.Firefox(executable_path = "/usr/local/bin/geckodriver")
如果没有下载geckodriverckod或是没有指明geckodriverckod的路径,执行执行程序会报错,如下:
Traceback (most recent call last):
File "/Users/evan/evan/Eclipse/Selenium/src/Selenium_learn/learn_1.py", line 14, in <module>
driver = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-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 be in PATH.
标签:cut space style rck init driver 执行 tab mos
原文地址:http://www.cnblogs.com/gforc/p/7391234.html