[英]Splinter Selenium Phantomjs Driver failing on instantiation
我正在嘗試使用Python + Splinter + Selenium + PhantomJS進行基本測試,但我無法啟動phantomjs瀏覽器。 (Chrome和Firefox驅動程序工作正常。)當我運行時:
from splinter import Browser
b = Browser('phantomjs')
我收到錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/splinter/browser.py", line 63, in Browser
return driver(*args, **kwargs)
File "/Library/Python/2.7/site-packages/splinter/driver/webdriver/phantomjs.py", line 32, in __init__
self.driver = PhantomJS(desired_capabilities=capabilities, **kwargs)
File "/Library/Python/2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 56, in __init__
desired_capabilities=desired_capabilities)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 141, in start_session
'desiredCapabilities': desired_capabilities,
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 199, in execute
response = self.command_executor.execute(driver_command, params)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 395, in execute
return self._request(command_info[0], url, body=data)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 463, in _request
resp = opener.open(request, timeout=self._timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
另外,當我跑:
from selenium import webdriver
d = webdriver.PhantomJS()
我得到了基本相同的錯誤。
看起來PhantomJS正在使用遠程驅動程序連接到遠程服務器,但是分裂器沒有啟動用於PhantomJS連接的selenium(?)服務器。 我不介意進入splinter(?)的源代碼並更改一些東西以使其工作。 但是,我無法確定解決這個問題的方法。
或者,我是否需要手動啟動服務器以便PhantomJS連接?
(作為參考,Ruby + Cucumber + Capybara + Poltergeist在我的盒子上工作正常。)這是我的軟件的配置。
$ python --version
Python 2.7.10
$ pip show splinter | grep Version
Metadata-Version: 1.1
Version: 0.7.3
$ pip show selenium | grep Version
Metadata-Version: 2.0
Version: 2.47.3
$ phantomjs -v
2.0.0
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.5
BuildVersion: 14F27
只是想分享phantomjs
+ splinter
與我的機器下面的配置很好地工作:
~ $ python --version
Python 2.7.11
~ $ pip show splinter | grep Version
Metadata-Version: 1.1
Version: 0.7.3
~ $ pip show selenium | grep Version
Metadata-Version: 2.0
Version: 2.47.3
~ $ phantomjs -v
2.0.0
~ $ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11
BuildVersion: 15A284
我有同樣的錯誤。 然后我檢查我的/ etc / hosts並刪除不必要的localhost別名。 所有的工作。 檢查你的/ etc / hosts
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.