【问题标题】:Nightwatch JS - How to run tests via Firefox headlessNightwatch JS - 如何通过 Firefox 无头运行测试
【发布时间】:2018-06-19 09:46:14
【问题描述】:

这是我的 Selenium 设置:

            "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 已成功打开并进行测试,但不是无头模式。

我正在使用的版本:

  • Firefox 60(64 位)
  • 硒 3.4
  • Geckodriver 0.20(64 位)

【问题讨论】:

  • 你可以试试"args" : ["headless", "no-sandbox", "disable-gpu"]

标签: node.js selenium nodes nightwatch.js geckodriver


【解决方案1】:

我使用以下配置进行此操作 - 主要区别在于未设置 alwaysMatch 和 args 双破折号:--headless

另请注意,在将env 指定为vue-cli-service 时,它需要一个空格,而不是环境名称前的=,即:

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

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

【讨论】:

    【解决方案2】:

    我的nightwatch.jsongeckodriver/Capabilities.html#capabilities-example 一样工作,只使用单个破折号-headless

    geckodriver 版本 0.24.0 (2019-01-28) 与 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" ]
                        }
                    }
    
                }
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 2020-07-18
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      相关资源
      最近更新 更多