打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
python – Splinter Selenium Phantomjs驱动程序在实例化时失败

我正在尝试使用Python Splinter Selenium PhantomJS进行基本测试,但我无法启动phantomjs浏览器. (Chrome和Firefox驱动程序工作正常.)当我运行时:

from splinter import Browserb = 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 webdriverd = webdriver.PhantomJS()

我得到了基本相同的错误.

看起来PhantomJS正在使用远程驱动程序连接到远程服务器,但是分裂器没有启动用于PhantomJS连接的selenium(?)服务器.我不介意进入splinter(?)的源代码并更改一些东西以使其工作.但是,我无法确定解决这个问题的方法.

或者,我是否需要手动启动服务器以便PhantomJS连接?

(作为参考,Ruby Cucumber Capybara Poltergeist在我的盒子上工作正常.)
这是我的软件配置.

$python --versionPython 2.7.10$pip show splinter | grep VersionMetadata-Version: 1.1Version: 0.7.3$pip show selenium | grep VersionMetadata-Version: 2.0Version: 2.47.3$phantomjs -v2.0.0$sw_versProductName:    Mac OS XProductVersion: 10.10.5BuildVersion:   14F27

解决方法:

只想在我的机器上使用以下配置很好地分享phantomjs splinter:

~ $python --versionPython 2.7.11~ $pip show splinter | grep VersionMetadata-Version: 1.1Version: 0.7.3~ $pip show selenium | grep VersionMetadata-Version: 2.0Version: 2.47.3~ $phantomjs -v2.0.0~ $sw_versProductName:    Mac OS XProductVersion: 10.11BuildVersion:   15A284
来源:https://www.icode9.com/content-1-317901.html
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Selenium2+python自动化69-PhantomJS使用
RobotFramework+seleniumlibrary Web自动化测试 (三)
Selenium Webdriver集合大系列[+精]
入手爬虫利器:phantomjs+selenium、自动填充文本框、自动点按钮
Python爬虫入门,快速抓取大规模数据(第四部分)
使用python/casperjs编写终极爬虫-Google Keyword Tool Scraper(selenium+python version)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服