试图在win7上设置selenium / phantomjs的路径

时间:2014-01-18 19:41:06

标签: python selenium phantomjs

我正在努力完成http://blog.likewise.org/2013/04/webdriver-testing-with-python-and-ghostdriver/。我的开发环境是win7上的USB驱动器。我有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 

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

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

pip install selenium==2.37

到目前为止,这一直在为我工作,尽管上述文章表明至少存在一些问题。