node.js - 无法创建新服务: GeckoDriverService

标签 node.js windows selenium nightwatch.js

我是网络自动化的初学者。我尝试从 This YouTube Tutorial 运行 Nightwatch 教程.

我在 Windows 10 上安装了以下工具:

  • node.js
  • selenium-server-standalone-3.9.1
  • nightwatch.js 0.9.19

当我执行命令时

node nightwatch.js -t test/google.js

我收到错误

'{ 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: \'DESKTOP-I986AE6\', ip: \'172.29.218.145\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'9.0.4\'\nDriver info: driver.version: unknown',
 error: 'session not created' },status: 33 }

我见过This Post 。然后我下载了驱动程序(geckodriver 和 chromedriver)并将驱动程序放在与我的 json 文件相同的目录中。然后我在 json 文件中插入驱动程序的路径,但仍然遇到相同的错误。我该如何解决这个问题?

我的 nightwatch.json 文件:

{
  "src_folders" : ["tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "page_objects_path" : "",
  "custom_assertions_path" : "",
  "globals_path" : "",
  "live_output" : false,
  "parallel_process_delay" : 10,
  "disable_colors": false,
  "test_workers" : false,

  "selenium" : {
    "start_process" : false,
    "server_path" : "",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4445,
    "cli_args" : {
      "webdriver.chrome.driver" : "chromedriver.exe",
      "webdriver.gecko.driver" : "geckodriver.exe",
      "webdriver.firefox.profile" : ""
    }
  },

  "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
      }
    },

    "saucelabs" : {
      "selenium_host" : "ondemand.saucelabs.com",
      "selenium_port" : 80,
      "username" : "${SAUCE_USERNAME}",
      "access_key" : "${SAUCE_ACCESS_KEY}",
      "use_ssl" : false,
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "on_failure" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox"
      },
      "globals" : {
        "myGlobal" : "some_sauce_global"
      },
      "selenium" : {
        "start_process" : false
      }
    },

    "phantomjs" : {
      "desiredCapabilities" : {
        "browserName" : "phantomjs",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true,
        "phantomjs.binary.path" : "/path/to/phantomjs"
      }
    },

    "browserstack" : {
      "selenium" : {
        "start_process" : false
      },
      "selenium_host" : "hub.browserstack.com",
      "selenium_port" : 80,
      "silent" : true,
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox",
        "browserstack.user" : "...",
        "browserstack.key" : "..."
      }
    },

    "testingbot" : {
      "selenium_host" : "hub.testingbot.com",
      "selenium_port" : 80,
      "apiKey" : "${TB_KEY}",
      "apiSecret" : "${TB_SECRET}",
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "on_failure" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox"
      },
      "selenium" : {
        "start_process" : false
      }
    }
  }
}

最佳答案

不,这不是强制性的。司机可以在任何地方,只要可以到达。 在第一个示例中,尝试将 ./ 放在可执行文件之前,以明确指出它们与 JSON 位于同一目录中,如下所示:

 "cli_args" : {
  "webdriver.chrome.driver" : "./chromedriver.exe",
  "webdriver.gecko.driver" : "./geckodriver.exe",
  "webdriver.firefox.profile" : ""
}

关于node.js - 无法创建新服务: GeckoDriverService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48789132/

相关文章:

windows - 如何将 Git for Windows 软件安装到特定目录?

java - 如何点击左侧菜单项

selenium - 需要使用Java在Selenium Webdriver中使用XPath选择特定元素

java - Selenium Webdriver -dragAndDrop 在 Firefox 32 中不起作用

mysql - NodeJS 在本地主机上工作但不能在线工作

node.js - Nodejs/Express/Cookies : how do you set signed cookies with a secret

使用源代码行号调试 node.js

node.js - 文件替换不适用于 e2e 测试

windows - 据我所知,你不能在Windows上编译Swift,那么SwiftStub如何在Windows上编译代码呢?

windows - 使用py2exe自带的python解释器