gpt4 book ai didi

node.js - Nightwatch JS - 如何通过 Firefox headless 运行测试

转载 作者:搜寻专家 更新时间:2023-10-31 23:40:03 24 4
gpt4 key购买 nike

这是我的 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 正在成功打开并进行测试,但不是在 headless 模式下。

我使用的版本:

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

最佳答案

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

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

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

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

关于node.js - Nightwatch JS - 如何通过 Firefox headless 运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50925278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com