【问题标题】:Cannot load page on Firefox when testing localhost with Nightwatch and Selenium使用 Nightwatch 和 Selenium 测试 localhost 时无法在 Firefox 上加载页面
【发布时间】:2017-04-21 23:51:05
【问题描述】:

我正在使用 Nightwatch(Selenium WebDriver API 的节点包装器)构建一套自动化集成测试。我能够让它在 Chrome 上正常工作,但不能在 Firefox(或 Safari,就此而言)。

我认为问题与 GeckoDriver 与 Firefox 驱动程序有关。我已将 Nightwatch 配置为在我的 nightwatch.json 中使用 GeckoDriver。但是 Selenium 似乎正在寻找 Firefox 驱动程序,基于nightwatch -e firefox --verbose 的终端输出。见下文:

INFO Request: POST /wd/hub/session/2c156cf4-10cb-44b2-8b1f-c12312b4633f/url 
 - data:  {"url":"localhost:9000"} 
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":24}
ERROR Response 500 POST /wd/hub/session/2c156cf4-10cb-44b2-8b1f-c12312b4633f/url (1218ms) { state: 'unknown error',
  sessionId: '2c156cf4-10cb-44b2-8b1f-c12312b4633f',
  hCode: 1111219279,
  value: 
   { additionalInformation: '\nDriver info: org.openqa.selenium.firefox.FirefoxDriver\nCapabilities ...

这是我的 Nightwatch 配置文件:

{
  "src_folders": ["./nightwatch/tests"],
  "output_folder": "./nightwatch/reports",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "./nightwatch/tests/pages",
  "globals_path": "",

  "selenium": {
    "start_process": true,
    "server_path": "./nightwatch/selenium-server-standalone-3.4.0.jar",
    "log_path": false,
    "cli_args": {
      "webdriver.chrome.driver": "./nightwatch/drivers/chromedriver",
      "webdriver.gecko.driver": "./nightwatch/drivers/geckodriver"
    }
  },

  "test_settings": {
    "default": {
      "desiredCapabilities": {
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },

    "chrome": {
      "desiredCapabilities": {
        "browserName": "chrome"
      }
    },

    "firefox": {
      "desiredCapabilities": {
        "browserName": "firefox",
        "marionette": true
      }
    }
  }
}

为了更好地衡量,这是我在测试中尝试访问的 nightwatch/pages/index.js 文件:

module.exports = {
  url: 'localhost:9000',
  elements: {
    // stuff
  }
}

【问题讨论】:

    标签: firefox selenium-webdriver nightwatch.js geckodriver


    【解决方案1】:

    不管怎样,目前我们决定坚持使用当前的 ESR 版本的 Firefox,它可以与开箱即用的 Selenium 一起使用。

    我们对这个新版本的 Firefox 和新驱动程序进行了一些尝试,但它不够稳定,无法继续。

    我的建议是安装 ESR 版本的 Firefox,看看你能不能让它这样工作。如果是,则进行下一步(即,针对最新版本进行测试)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-23
      • 2022-01-26
      • 2014-05-11
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多