我正试图通过Webdriver.io、Selenium和ChromeDriver在Mac上运行自动化测试。我正在使用所有相关软件的最新版本:
当我试图从CLI运行wdio时,我得到以下输出:
$ ./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图标在码头上弹出一会儿,然后立即消失。
我尝试从CLI启动Selenium独立服务器,导航到http://localhost:4444/wd/hub/static/resource/hub.html,并尝试在那里手动启动Chrome会话,但结果是一样的: Chrome图标弹出,消失,Selenium抛出一个“无法创建新会话”的错误。
我也尝试过下载一个较旧版本的铬,并强迫ChromeDriver使用它,但它只是无法启动可执行文件。
发布于 2018-02-14 09:10:40
在这里找到了解决方案:https://github.com/Polymer/web-component-tester/issues/573#issuecomment-310828303
引用:
经过一番努力,我终于修好了。之所以发生这种情况,是因为我的本地主机是按照新的Ipv6标准(如:1)映射的,但是selenium需要127.0.0.1的ipv4地址。因此,我不得不使用系统中的命令来更改它,如下所示: 打开终端窗口并键入这一行: 数独打开-a TextEdit /etc/主机 您将被提示输入您的管理密码和您的主机文件将打开在TextEdit。在主机文件中添加这一行: 127.0.0.1本地主机 保存文件并关闭。就这样。
(增编: TextEdit拒绝为我保存文件,即使是超级用户,所以我使用了sudo vim /etc/hosts )
发布于 2020-06-19 12:25:10
Google浏览器正在日新月异地更新,您需要使用chrome驱动程序exe,根据我们计算机中使用的浏览器版本请使用最新的铬驱动程序和浏览器版本的https://chromedriver.chromium.org/downloads。
https://stackoverflow.com/questions/48770943
复制相似问题