Yo Dawgy Dawg
Yo Dawgy Dawg

Reputation: 70

Nightwatch JS - How to run tests via Firefox headless

Here's my Selenium settings:

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

My Firefox setup:

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

Firefox is successfully opening and doing the tests but not in headless mode.

Versions I am using:

Upvotes: 4

Views: 4496

Answers (2)

liratanak
liratanak

Reputation: 97

my nightwatch.json worked as in geckodriver/Capabilities.html#capabilities-example use only single dash -headless

geckodriver version 0.24.0 ( 2019-01-28) with firefox 65

{
    "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" ]
                    }
                }

            }
        }
    }
}

Upvotes: 4

match
match

Reputation: 11060

I have this working with the following config - the main differences being not setting alwaysMatch and the args double-dash: --headless.

Also note that when specifying env to vue-cli-service it expects a space, not an = before the env name, i.e.:

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

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

Upvotes: 4

Related Questions