【问题标题】:Selenium doesn't start webdriverSelenium 不启动 webdriver
【发布时间】:2017-06-18 12:37:59
【问题描述】:

版本

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

我正在使用守夜人,但那 sh 我也尝试过

我正在使用 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.使用在另一个终端上为应用程序提供服务的快递服务器 2.没有快递服务器 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 selenium-chromedriver nightwatch.js


    【解决方案1】:

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

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

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

    【讨论】:

    • 我收到一条 selenium 消息:Whoops! The URL specified routes to this help page. 你是什么意思还没有关闭端口 4444?它应该是打开的,这就是测试运行的地方
    • 对,我认为它正在被另一个 Selenium 实例使用。我是说它没有关闭。 Nightwatch 为每个测试脚本处理 Selenium 的启动和关闭。
    • 我还在上面编辑了我的答案以进行澄清。
    • 是的,在问题的顶部添加了我的版本,谢谢
    猜你喜欢
    • 2017-07-30
    • 2018-06-10
    • 2013-12-05
    • 2017-10-24
    • 2015-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多