【发布时间】:2015-07-04 08:56:09
【问题描述】:
我正在尝试在 Python 中运行 PhantomJS 驱动程序,但出现错误。我读过我应该将整个路径作为参数传递,但它没有帮助。
代码如下:
from selenium import webdriver
# driver = webdriver.Chrome('D:\Python_projects\chromedriver_win32/chromedriver.exe') # this works
driver = webdriver.PhantomJS(executable_path='D:\Python\phantomjs-2.0.0-windows\bin\phantomjs.exe')
错误:
Traceback (most recent call last):
File "path to script", line 8, in <module>
driver = webdriver.PhantomJS(executable_path='D:\Python\phantomjs-2.0.0-windows\bin\phantomjs.exe')
File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 50, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\service.py", line 75, in start
raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
selenium.common.exceptions.WebDriverException: Message: Unable to start phantomjs with ghostdriver.
Screenshot: available via screen
你知道我做错了什么吗?
【问题讨论】:
-
@MalikBrahimi 文档说应该给出可执行文件的路径 - selenium.googlecode.com/svn/trunk/docs/api/py/…
-
为什么不在系统路径中添加包含可执行文件的目录?
-
无法在 Windows 上使用 Selenium 2.44.0 和 PhantomJS 2.0.0 进行复制。
标签: python selenium browser phantomjs