python - 尝试在win7上设置selenium/phantomjs的路径

标签 python selenium phantomjs

我正在尝试解决http://blog.likewise.org/2013/04/webdriver-testing-with-python-and-ghostdriver/ 。我的开发环境是win7上的U盘。我有 phantomjs.exe:

f:/phantomjs.exe

使用 python REPL,我根据本文完成了以下操作:

>>> from selenium import webdriver
>>> driver = webdriver.PhantomJS(executable_path="F:\phantomjs.exe")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "F:\envs\r1\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 50, in __init__
    self.service.start()
  File "F:\envs\r1\lib\site-packages\selenium\webdriver\phantomjs\service.py", line 66, in start
    raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
WebDriverException: Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen 

我该如何解决这个问题?

最佳答案

已关注 Can't run PhantomJS in python via Selenium ,我从我的 virtualenv 中卸载了 selenium 并运行:

pip install selenium==2.37

到目前为止,这对我来说一直有效,尽管上面的文章表明至少存在一些问题。

关于python - 尝试在win7上设置selenium/phantomjs的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21208948/

相关文章:

python - StaleElementReferenceException selenium webdriver python

javascript - 如何更改 CasperJS 地理定位以进行抓取?

python - 为什么 eval 找不到在外部函数中定义的变量?

python - 检测 json schema 是否具有 oneOf 类型 schema

selenium - HtmlUnit 的稳定性和速度如何

Python Selenium Webdriver 检查元素是否不存在需要时间

python - 使用 Splinter + PhantomJS (Python) 访问表单

python - 安装适用于 Python 3.1 的 oursql 时出错

python - 在哪里放置reverse=True?

firefox - WebDriver/打开上传文件窗口时卡住