我正在尝试解决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/