【发布时间】:2019-09-06 05:21:21
【问题描述】:
我正在尝试在 bitbucket 管道中部署时使用 nightwatch 运行我的 E2E 测试。我在本地安装了 nightwatch,在我的 Windows 机器上安装了 chromedriver,一切正常。
当我在管道中运行 npm nightwatch 时收到此错误
An error occurred while trying to start ChromeDriver: cannot resolve path: "/opt/atlassian/pipelines/agent/build/node_modules/chromedriver/lib/chromedriver/chromedriver". Please check that the "webdriver.server_path" config property is set correctly.
这是它指定的路径的文件结构
文件结构
node_modules/
chromedriver/
lib/
chromdriver/
chromerdriver.exe
chromedriver_win32.zip
很明显node_modules/chromedriver/lib/chromedriver/chromedriver 不存在。容器是Linux所以它不知道如何执行chromedriver.exe文件。
那么如何让 bitbucket 管道运行 chromedriver.exe?或者我如何让chromedriver 进入它正在寻找的路径。我很肯定以前有人遇到过这种情况。在这方面苦苦挣扎了一段时间,正在寻求帮助。谢谢。
bitbucket-pipelines.yml 文件
image: rastasheep/alpine-node-chromium
pipelines:
custom:
develop:
- step:
name: Serve and Test
caches:
- node
script:
- apt-get update && apt-get install -yq libnss3
- if [ ! -d "node_modules/nightwatch" ]; then npm install; fi
- npm start
- npm run nightwatch
nightwatch.conf.js
const chrome = require('chromedriver')
module.exports = {
'src_folders': [
'./nightwatch/tests/elements'
],
'output_folder': './nightwatch/reports',
'globals_path': './nightwatch/utils/globals/globals.js',
'webdriver': {
'start_process': true,
'server_path': chrome.path,
'log_path': './nightwatch/reports',
'cli_args': [
'--verbose'
],
'port': 9515
},
'test_settings': {
'default': {
'launch_url': 'http://localhost:3100',
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'chromeOptions': {
'args': [
'no-sandbox',
'headless'
]
}
},
'screenshots': {
'enabled': true,
'on_failure': true,
'on_error': true,
'path': 'nightwatch/screenshots'
}
}
}
}
【问题讨论】:
标签: selenium-chromedriver nightwatch.js bitbucket-pipelines