作为CI项目的一部分,我正在设置夜间监视测试脚本并从Jenkins服务器运行它们。
当我进入项目并运行命令“ nightwatch”时,我能够在服务器(centOS)上运行脚本。
我遇到的问题是,从詹金斯(Jenkins)运行时,我不能仅将CD插入项目目录(我是可以的,但这并不聪明)。 所以我这样运行:
/usr/local/bin/nightwatch -c /PATH_TO_PROJECT/nightwatch.json
-c此处是配置文件参数,看起来像这样:
{
"src_folders": [
"/PATH_TO_PROJECT/tests"
],
"output_folder": "/PATH_TO_PROJECT/reports",
"page_objects_path": [
"/PATH_TO_PROJECT/page-objects"
],
"selenium": {
"start_process": true,
"server_path": "/PATH_TO_PROJECT/bin/selenium-server-standalone-3.14.0.jar",
"log_path": "/PATH_TO_PROJECT/log/",
"port": 4444,
"cli_args": {
"webdriver.gecko.driver": "/PATH_TO_PROJECT/bin/geckodriver"
}
},
"test_settings": {
"default": {
"launch_url": "http://localhost",
"selenium_port": 4444,
"selenium_host": "localhost",
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true,
"alwaysMatch" : {
"moz:firefoxOptions": {
"args": ["-headless", "no-sandbox", "disable-gpu"]
}
}
}
}
}
}
当我运行命令:/usr/local/bin/nightwatch -c /home/mbajwa/salesforce-nightwatch_js-master_final_S/nightwatch.json
我收到此错误:ERROR: Unable to locate element: "//*[@id='AllTab_Tab']" using: xpath
这是我的脚本尝试查找的所有元素。
有人知道我还需要作为命令行参数传递哪些其他文件吗?我以为配置文件可以解决所有问题。