使用Firefox从Nightwatch.js自动运行Selenium时出错 [英] Error running Selenium automatically from Nightwatch.js with Firefox

查看:67
本文介绍了使用Firefox从Nightwatch.js自动运行Selenium时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在运行nightwatch.js测试用例时自动启动Selenium Server.我将nightwatch.json上的硒设置更改为:

I want to start Selenium Server automatically when I run a nightwatch.js test case. I changed the selenium settings on nightwatch.json to:

  "selenium" : {
    "start_process" : true,
    "server_path" : "./selenium/selenium391.jar",
    "log_path" : "C:/Projects/reports",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./selenium/chromedriver.exe",
      "webdriver.ie.driver" : "./selenium/IEDriverServer.exe",
      "webdriver.firefox.profile" : "./selenium/geckodriver.exe"
    }
  },

当我将Chrome用作浏览器时,此配置有效.但是,使用Firefox运行它时出现错误:

This configuration works when I use Chrome as browser. However I got an error when I run it using Firefox:

ERROR Response 500 POST /wd/hub/session (312ms) { value:
   { message: 'Unable to create new service: GeckoDriverService\nBuild info: ver
sion: \'3.9.1\', revision: \'63f7b50\', time: \'2018-02-07T22:42:28.403Z\'\nSyst
em info: host: \'IBS-PC192\', ip: \'192.168.1.115\', os.name: \'Windows 7\', os.
arch: \'x86\', os.version: \'6.1\', java.version: \'1.8.0_112\'\nDriver info: dr
iver.version: unknown',
     error: 'session not created' },
  status: 33 }

如果我手动运行Selenium Server,则夜间监视测试可在Firefox上运行.我该如何解决?

If I run the Selenium Server manually, the nightwatch test works on Firefox. How do I resolve this?

nightwatch.json文件:(对于Firefox)

nightwatch.json file: for Firefox

{
  "src_folders" : ["tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "page_objects_path" : "",
  "custom_assertions_path" : "",
  "globals_path" : "C:/Projects/global/globals.js",
  "live_output" : false,
  "parallel_process_delay" : 10,
  "disable_colors": false,
  "test_workers" : false,

  "selenium" : {
    "start_process" : true,
    "server_path" : "./selenium/selenium391.jar",
    "log_path" : "C:/Projects/reports",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./selenium/chromedriver.exe",
      "webdriver.ie.driver" : "./selenium/IEDriverServer.exe",
      "webdriver.firefox.profile" : "./selenium/geckodriver.exe"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_host" : "127.0.0.1",
      "selenium_port" : 4444,
      "silent" : true,
      "disable_colors": false,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities" : {
        "browserName" : "firefox",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
    },

selenium-debug.log的内容

14:24:00.791 INFO - Selenium build info: version: '3.9.1', revision: '63f7b50'
14:24:00.791 INFO - Launching a standalone Selenium Server on port 4444
2018-02-16 14:24:00.853:INFO::main: Logging initialized @280ms to org.seleniumhq.jetty9.util.log.StdErrLog
2018-02-16 14:24:00.962:INFO:osjs.Server:main: jetty-9.4.7.v20170914, build timestamp: 2017-11-21T22:27:37+01:00, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8
2018-02-16 14:24:00.978:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@5ed7a6{/,null,STARTING} has uncovered http methods for path: /
2018-02-16 14:24:00.978:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5ed7a6{/,null,AVAILABLE}
2018-02-16 14:24:01.352:INFO:osjs.AbstractConnector:main: Started ServerConnector@18f65a4{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2018-02-16 14:24:01.352:INFO:osjs.Server:main: Started @782ms
14:24:01.352 INFO - Selenium Server is up and running on port 4444
2018-02-16 14:24:01.540:INFO:osjshC.ROOT:qtp17048053-10: org.openqa.selenium.remote.server.WebDriverServlet-132ec19: Initialising WebDriverServlet
14:24:01.618 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@1e1a802
14:24:01.618 INFO - /session: Executing POST on /session (handler: BeginSession)
14:24:01.680 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: firefox, javascriptEnabled: true, name: Google Wiki}
14:24:01.680 INFO - Capabilities {acceptSslCerts: true, browserName: firefox, javascriptEnabled: true, name: Google Wiki} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)

推荐答案

您所看到的错误确实为我们提供了一些有关发生问题的提示,如下所示:

The error you are seeing does gives us some hint about whats going wrong as follows :

ERROR Response 500 POST /wd/hub/session (312ms) { value: { message: 'Unable to create new service: GeckoDriverService\nBuild info: version: \'3.9.1\', revision: \'63f7b50\', time: \'2018-02-07T22:42:28.403Z\'\nSystem info: host: \'IBS-PC192\', ip: \'192.168.1.115\', os.name: \'Windows 7\', os.arch: \'x86\', os.version: \'6.1\', java.version: \'1.8.0_112\'\nDriver info: driver.version: unknown', error: 'session not created' }, status: 33 }

超文本传输​​协议(HTTP) Response 500 服务器错误响应代码表示服务器遇到意外情况,阻止其满足请求.

The HyperText Transfer Protocol (HTTP) Response 500 server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

主要原因是您使用的二进制文件 不兼容为:

The main reason is the binaries you are using are incompatible as :

  • Selenium Client 版本与 selenium391.jar 发布'2018-02-07T22:42:28.403Z'
  • 但是 JDK 版本的版本为 java.version:'1.8.0_112 ,这是古代的.
  • Selenium Client version is as selenium391.jar released '2018-02-07T22:42:28.403Z'
  • But the JDK version is as java.version: '1.8.0_112 which is pretty ancient.

一种快速的解决方案是:

A quick solution would be to :

  • Update the JDK version to recent levels i.e. Java SE Development Kit 8u161
  • Run CCleaner tool to wipe off the OS chores before and after executing your Test Suite

正如您在评论中提到的那样,您仍然遇到相同的错误,您需要更改以下行:

As you mentioned in your comment that you still got the same error you need to change the following line :

"webdriver.firefox.profile" : "./selenium/geckodriver.exe"

收件人:

"webdriver.gecko.driver" : "./selenium/geckodriver.exe"

这篇关于使用Firefox从Nightwatch.js自动运行Selenium时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆