Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Firefox 60 (64 bit)
  • Selenium 3.4
  • Geckodriver 0.20 (64 bit)
like image 613
Yo Dawgy Dawg Avatar asked Jan 27 '23 21:01

Yo Dawgy Dawg


1 Answers

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"]
      }
    }
  }
like image 152
match Avatar answered Feb 12 '23 03:02

match