gpt4 book ai didi

linux - 在 linux box 上运行 nightwatch.js 测试?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:24:26 26 4
gpt4 key购买 nike

我正在尝试在安装了 Centos OS 的 linux 机器上运行 nightwatch 自动化 ui 测试。我在开始时遇到了问题。

这是我在 nightwatch.json 中的 test_settings 配置

"test_settings": {
"default": {
"launch_url": "",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": true,
"path": "./screenshots"
},
"detailed_option": true,
"end_session_on_fail": false,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream"
]
}
}
},

我安装了 linux 64 位 chrome 驱动程序。然后我安装了 selenium 独立服务器。但是当我想要使用 node nightwatch 进行 nightwatch 测试时,我得到一个错误

“连接被拒绝!Selenium 未启动..”

如何设置 linux box 来运行 nightwatch 自动化 UI 测试?

当我将 start_process 设置为 false 并单独运行 selenium 服务器时,出现以下错误:

14:23:41.158 WARN - Exception: unknown error: Chrome failed to start: exited abnormally

最佳答案

您的 nightwatch.json 看起来缺少许多对象,特别是 selenium 服务器设置,这将解释 “连接被拒绝!Selenium 未启动..”。例如,这是我的,其中大部分将特定于您的环境:

{
"src_folders": ["./tests"],
"output_folder": "reports",
"custom_commands_path": [
"./node_modules/testarmada-magellan-nightwatch/lib/commands",
"./lib/custom_commands"
],
"custom_assertions_path": [
"./node_modules/testarmada-magellan-nightwatch/lib/assertions"
],

"page_objects_path": [
"./lib/pages"
],

"selenium": {
"start_process": true,
"server_path": "./node_modules/testarmada-magellan-nightwatch/node_modules/selenium-server/lib/runner/selenium-server-standalone-2.52.0.jar",
"log_path": "reports",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/testarmada-magellan-nightwatch/node_modules/chromedriver/lib/chromedriver/chromedriver",
"webdriver.ie.driver": ""
}
},

"test_settings": {
"default": {
"launch_url": "http://127.0.0.1",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"sync_test_names": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome"
},
"globals": {
"waitForConditionTimeout": 60000
}
},

"phantomjs": {
"desiredCapabilities": {
"browserName": "phantomjs",
"javascriptEnabled": true,
"acceptSslCerts": true,
"phantomjs.binary.path": "./node_modules/testarmada-magellan-nightwatch/node_modules/phantomjs/bin/phantomjs"
}
},

"safari": {
"desiredCapabilities": {
"browserName": "safari"
}
},

"firefox": {
"desiredCapabilities": {
"browserName": "firefox"
}
},

"chrome": {
"desiredCapabilities": {
"browserName": "chrome"
}
},

"sauce": {
"selenium_host": "ondemand.saucelabs.com",
"selenium_port": 80,
"username": "myUserName",
"access_key": "",
"desiredCapabilities": {
"browserName": "${SAUCE_BROWSER_NAME}",
"platform": "${SAUCE_BROWSER_PLATFORM}",
"version": "${SAUCE_BROWSER_VERSION}",
"tunnel-identifier": "${SAUCE_TUNNEL_ID}"
},
"selenium": {
"start_process": false
}
}
}
}

关于linux - 在 linux box 上运行 nightwatch.js 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37616881/

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