Nightwatch JS - 如何通过firefox无头运行测试

问题描述 投票:2回答:2

这是我的硒设置:

            "selenium": {
                "start_process": true,
                "start_session": true,
                "server_path": "./nightwatch/drivers/selenium-server.jar",
                "log_path": "./nightwatch/reports",
                "host": "127.0.0.1",
                "port": 4444,
                "cli_args": {
                  "webdriver.chrome.driver": "nightwatch/drivers/chromedriver.exe",
                  "webdriver.gecko.driver": "nightwatch/drivers/geckodriver.exe",
                  "webdriver.ie.driver": "nightwatch/drivers/IEDriverServer.exe"
                }
              }

我的firefox设置:

            "firefox": {
                    "selenium_port": 4444,
                    "default_path_prefix": "/wd/hub",
                    "globals": {
                        "environment": "firefox"
                    },
                    "desiredCapabilities": {
                        "browserName": "firefox",
                        "alwaysMatch": {
                                    "moz:firefoxOptions": {
                                        "args": ["-headless"]
                                    }
                                }                           
                    }
                }

被困了好几天搞清楚了。 Firefox成功打开并进行测试但不是无头模式。

            Versions I am using:

            Firefox 60 (64 bit)
            Selenium 3.4
            Geckodriver 0.20 (64 bit)
node.js selenium nodes nightwatch.js geckodriver
2个回答
2
投票

我的nightwatch.jsongeckodriver/Capabilities.html#capabilities-example工作只使用单个划线-headless

使用firefox 65的geckodriver版本0.24.0(2019-01-28)

{
    "src_folders": ["tests"],

    "webdriver": {
        "start_process": true,
        "server_path": "./node_modules/.bin/geckodriver",
        "cli_args": [
            "--log", "debug"
        ],
        "port": 4444
    },

    "test_settings": {
        "default": {
            "desiredCapabilities": {
                "browserName": "firefox",
                "acceptInsecureCerts": true,
                "alwaysMatch": {
                    "moz:firefoxOptions": {
                        "args": [ "-headless" ]
                    }
                }

            }
        }
    }
}

1
投票

我使用以下配置 - 主要区别是没有设置alwaysMatch和args double-dash:--headless

还要注意,当指定envvue-cli-service时,它需要一个空格,而不是env名称之前的=,即:

vue-cli-service test:e2e --env FirefoxHeadless

"FirefoxHeadless": {
    "desiredCapabilities": {
      "browserName": "firefox",
      "acceptInsecureCerts": true,
      "moz:firefoxOptions": {
        "args": ["--headless"]
      }
    }
  }
© www.soinside.com 2019 - 2024. All rights reserved.