硒与ChromeDriver:未创建会话,无法连接到渲染器

本文介绍了硒与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 图标会在 Dock 上弹出片刻,然后立即消失.

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 图标弹出,消失,Selenium 抛出错误无法创建新会话."

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.

推荐答案

在这里找到解决方案:https://github.com/Polymer/web-component-tester/issues/573#issuecomment-310828303

引用:

经过一番努力,我终于把它修好了.这是因为我的 localhost 是根据新的 Ipv6 标准(如 [::1])映射的,但 selenium 需要 ipv4 地址,如 127.0.0.1.所以我不得不像这样使用系统中的命令来更改它:

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:未创建会话,无法连接到渲染器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1170

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1071

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this-&gt;id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:807

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this-&gt;id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:900

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:930

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:877

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:864

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:834

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1727

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1308