Firefox驱动程序无法使用FF49和Python启动Selenium 3.0.1 [英] Firefox driver can't start for Selenium 3.0.1 with FF49 and Python
问题描述
from selenium import webdriver
$ p
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
caps [marionette] = True
driver = webdriver.Firefox(capabilities = caps)
driver.get(http ://www.mahsumakbas.net)
print driver.title
driver.close()
错误是:
$ b
追踪(最近最后一次调用):
C:\Mahsum\DevelopmentWorkSpace\Eclipse\Java\selenium_proj\src\hello.py,
第6行,
driver = webdriver.Firefox(capabilities = caps)文件C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py,
行135,在 init
self.service.start()文件C:\Python27\lib\site-packages\selenium\webdriver\common\s ervice.py,
第71行,开始
os.path.basename(self.path),self.start_error_message)selenium.common.exceptions.WebDriverException:消息:'geckodriver'
可执行文件需要在PATH中。
异常AttributeError:'Service'对象没有任何属性
'process'in>
被忽略
Selenium Webdriver版本为: 3.0.1
Firefox: 49.0.2 >
geckodriver: v0.11.1-win64
我为Windows PATH变量添加了geckodriver路径。 b
问题在哪里?
解决方案您可以将geckodriver Python的路径,它将工作。
另外,如果你喜欢有一个干净的Python文件夹,你必须在初始化的时候声明geckodriver的路径。要么你每次运行你的脚本,要么按照你所说的做PATH。正如Naveen所建议的,在正确保存PATH之前需要重新启动。您也可以尝试在Windows命令行中运行此命令:
setx路径%path%; c:\path\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
i have following Selenium Webdriver script with Python. But i got error:
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities caps = DesiredCapabilities.FIREFOX caps["marionette"] = True driver = webdriver.Firefox(capabilities=caps) driver.get("http://www.mahsumakbas.net") print driver.title driver.close()
error is:
Traceback (most recent call last): File "C:\Mahsum\DevelopmentWorkSpace\Eclipse\Java\selenium_proj\src\hello.py", line 6, in driver = webdriver.Firefox(capabilities=caps) File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in init self.service.start() File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception AttributeError: "'Service' object has no attribute 'process'" in > ignored
Selenium Webdriver version is: 3.0.1
Firefox: 49.0.2
geckodriver: v0.11.1-win64i added geckodriver path to Windows PATH variable.
where is the problem?
解决方案You can place the 'geckodriver' .exe in the base path of Python and it will work.
Alternatively, you have to declare the path to geckodriver when initializing if you prefer to have a clean Python folder. Either do it every time you run your script or by PATH as you says you've done. As Naveen suggests, a reboot is necessary before a PATH is correctly saved. You could also try to run this in the Windows command line:
setx path "%path%;c:\path\to\geckodriver-folder"
这篇关于Firefox驱动程序无法使用FF49和Python启动Selenium 3.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!