硒和ChromeDriver:会话未创建,无法连接到渲染器 [英] Selenium & ChromeDriver: session not created, unable to connect to renderer

查看:110
本文介绍了硒和ChromeDriver:会话未创建,无法连接到渲染器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Mac上的Webdriver.io,Selenium和ChromeDriver运行自动化测试.我正在使用所有相关软件的最新版本:

I am trying to run automated tests via Webdriver.io, Selenium and ChromeDriver on Mac. I am using the latest versions of all involved software:

  • 硒3.9.1
  • ChromeDriver 2.35
  • Chrome 64
  • 操作系统:macOS High Sierra 10.13.3

当我尝试从CLI运行wdio时,得到以下输出:

When I try to run wdio from the CLI, I get the following output:

$ ./node_modules/.bin/wdio --spec ./test_js/specs/features/aggregated/dataAccessControl.feature.js

----------
selenium-standalone installation starting
----------

---
selenium install:
from: https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar
to: /PROJECT_PATH/node_modules/selenium-standalone/.selenium/selenium-server/3.9.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip
to: /PROJECT_PATH/node_modules/selenium-standalone/.selenium/chromedriver/2.35-x64-chromedriver
---
File from https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar has already been downloaded
---
File from https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip has already been downloaded


-----
selenium-standalone installation finished
-----
A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
    at Timeout.hasStarted [as _onTimeout] (/PROJECT_PATH/node_modules/selenium-standalone/lib/check-started.js:17:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

Continue...
ERROR: session not created exception
from disconnected: unable to connect to renderer
chrome
    at new RuntimeError (/PROJECT_PATH/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
    at Request._callback (/PROJECT_PATH/node_modules/webdriverio/build/lib/utils/RequestHandler.js:313:39)
    at Request.self.callback (/PROJECT_PATH/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/PROJECT_PATH/node_modules/request/request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/PROJECT_PATH/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:313:30)

然后,该过程停止. Chrome图标在底座上弹出一会儿,然后立即消失.

The process then stops. The Chrome icon pops up for a moment on the dock, then disappears immediately.

我尝试从CLI启动Selenium独立服务器,导航到 http ://localhost:4444/wd/hub/static/resource/hub.html 并尝试在此处手动启动Chrome会话,但结果是相同的:Chrome图标弹出,消失并抛出硒错误无法创建新会话."

I have tried starting the Selenium standalone server from the CLI, navigating to http://localhost:4444/wd/hub/static/resource/hub.html and trying to start a Chrome session manually there, but the result is the same: the Chrome icon pops up, disappears, and Selenium throws an error "Unable to create new session."

我还尝试过下载较旧版本的Chromium,并强制ChromeDriver使用该版本,但它只是无法启动可执行文件.

I have also tried downloading an older version of Chromium and forcing ChromeDriver to use that, but it's just unable to launch the executable.

推荐答案

在此处找到解决方案:

Found the solution here: https://github.com/Polymer/web-component-tester/issues/573#issuecomment-310828303

报价:

最后,经过大量的努力,我将其修复.发生这种情况是因为我的本地主机是根据新的Ipv6标准(例如[:: 1])映射的,但是硒需要类似127.0.0.1的ipv4地址.所以我不得不像这样在我的系统中使用命令来更改它:

Finally i got it fixed after lot of struggle. It was happening because my localhost was mapped according to new Ipv6 standard like [::1] but the selenium needed the ipv4 address like 127.0.0.1. so i had to change it using the command in my system like this :

打开一个终端窗口,然后输入以下行:

Open a terminal window and type this line:

sudo open -a TextEdit/etc/hosts

sudo open -a TextEdit /etc/hosts

系统将提示您输入管理员密码,您的主机文件将在TextEdit中打开.在主机文件中添加以下行:

You will be prompt to type in your admin password and your host file will open in TextEdit. Add this line in your host file :

127.0.0.1本地主机

127.0.0.1 localhost

保存文件并关闭.就是这样.

Save the file and close. That's it.

(附录:TextEdit拒绝以超级用户身份保存文件,所以我改用sudo vim /etc/hosts)

(addendum: TextEdit refused to save the file for me, even as superuser, so I used sudo vim /etc/hosts instead)

这篇关于硒和ChromeDriver:会话未创建,无法连接到渲染器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆