Selenium 不启动 webdriver

标签 selenium selenium-chromedriver nightwatch.js

版本

"nightwatch": "^0.9.16" 
"chromedriver": "^2.30.1"
"selenium-server-standalone-jar": "^3.4.0"

我正在使用 Nightwatch,但是那是 我也尝试过

我正在使用nightwatchthis repo 中运行 Selenium我尝试过 chrome 和 firefox 驱动程序,但都没有成功。

我有selenium standalonechromedriver包,并且我知道 nightwatch.conf.js 上的路径是正确的:

const jar = require('selenium-server-standalone-jar')
console.log(jar.path) // logs /home/goldylucks/apps/ci-workshop/node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.4.0.jar
const chromedriver = require('chromedriver')
console.log(chromedriver.path) // logs /home/goldylucks/apps/ci-workshop/node_modules/chromedriver/lib/chromedriver/chromedriver

'selenium': {
  'start_process': true,
  'server_path': jar.path,
  'log_path': '',
  'port': 4444,
  'cli_args': {
    'webdriver.chrome.driver': chromedriver.path,
    'webdriver.ie.driver': '',
  },
},

'test_settings': {
  'chrome': {
    'desiredCapabilities': {
      'browserName': 'chrome',
      'javascriptEnabled': true,
      'acceptSslCerts': true,
    },
  },

但是当我运行测试时它超时并挂起:

$ yarn e2e:ui
yarn e2e:ui v0.24.6
$ nightwatch -e chrome 
Starting selenium server... started - PID:  12936

[App E2e Ui] Test Suite
===========================
 ✖ Timed out while waiting for element <body> to be present for 5000 milliseconds.  - expected "visible" but got: "not found"
    at Object.before (/home/goldylucks/apps/ci-workshop/test/ui/app.e2e-ui.js:9:8)

我尝试了以下组合: 1. 使用在另一个终端上为应用程序提供服务的 Express 服务器 2.没有 express 服务器 3.上述每一项都使用 chromedriver 在另一个终端手动启动(我真的认为这不重要,我应该这样做,只是想彻底......)

手动运行 chromedriver 会产生以下结果并挂起:

$ node_modules/chromedriver/lib/chromedriver/chromedriver
Starting ChromeDriver 2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5) on port 9515
Only local connections are allowed.

我也尝试使用 Firefox 运行,但它不起作用,这让我相信问题比 chromedriver 更深,即与 selenium 与 nightwatch 交互有关。

最佳答案

我记得这件事发生不久前。我认为这是以前的实例 Selenium 在关闭时没有关闭 释放端口 4444。尝试关闭 selenium 并重新启动。

为此,请在您选择的浏览器中手动打开以下网页。 http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer

然后尝试再次正常运行脚本。

关于Selenium 不启动 webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44501134/

相关文章:

java - RSelenium - Java 启用

selenium - 使用 browsermob-proxy 的 Chrome 浏览器证书不是受信任的问题

python - 如何使用 Selenium 在另一个标签中查找自定义标签

python - 如何覆盖 selenium 中的默认 chrome 命令行开关集

python - Selenium 无法打开指定的 URL 并显示数据 :,

java - 有没有办法在我的测试自动化套件目录中自动更新 chromedriver?

javascript - 如何在守夜人中操纵输入对象的范围?

nightwatch.js - 如何在 nightwatchjs 中控制新窗口

ios - Nightwatch.js - 无法使用 Appium(iOS 模拟器)执行 touchAction 或滚动,寻找解决方案

java - org.openqa.selenium.NoSuchElementException : Unable to locate element: