我正在尝试使用Protractor + SauceLabs在Docker容器中进行自动端到端测试,并且收到错误消息:找不到update-config.json。运行' webdriver-manager更新'下载二进制文件。'我现在正在运行' webdriver-manager更新--standalone false'在运行端到端测试之前(独立,因为我不需要独立版本,这也需要java)。有趣的是,(可以在下面的命令行输出中看到)该命令有效并且我实际上可以找到update-config.json文件,但是我仍然得到相同的错误。这可能只是量角器的错误,但我想首先检查Stack Overflow。任何帮助将不胜感激,谢谢!
哦,当然测试工作在本地,即使我删除了nodemodules,运行npm install,npm运行e2e sauce,或清除它们,执行npm install,npm运行webdriver-update,npm运行e2e-sauce。< / p>
相关依赖项 &#34; @ angular / cli&#34;:&#34; 1.6.6&#34;, &#34;节点&#34;:&#34; 8.10.0&#34;, &#34; npm&#34;:&#34; 5.6.0&#34;, &#34;量角器&#34;:&#34; 5.1.2&#34;, &#34; ts-node&#34;:&#34; 4.1.0&#34;,
package.json命令:
"e2e-sauce": "ng e2e --port 8100 --env test --sauce",
"webdriver-update": "webdriver-manager update --standalone false --gecko false",
我正在运行的bash脚本:
# for testing purposes, normally environment variable
GIT_COMMIT=aTestCommit;
if [[ -z $GIT_COMMIT ]]; then
echo "\$GIT_COMMIT environment variable is required!";
exit 1;
fi
function cleanup {
docker rm -f $GIT_COMMIT
}
trap cleanup EXIT INT TERM
COMMAND=""
COMMAND+="npm run webdriver-update"
COMMAND+=" && ls ./node_modules/protractor/node_modules/webdriver-manager/selenium"
COMMAND+=" && ng e2e --port 8100 --env test --sauce"
set -ex
docker-compose create --build builder
docker-compose run --name $GIT_COMMIT builder bash -c "$COMMAND"
DockerFile:
FROM node:8
# Install Chrome
RUN \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \
apt-get update && \
apt-get install -y google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
# Set the working directory to /app
WORKDIR /app
# Give the node user access to /usr/local
RUN chown -R node:node /usr/local
# Give the node user access to /usr/local
RUN chown -R node:node /app
# Change to the node user
USER node
# Install the Angular CLI globally
RUN npm install -g @angular/cli@1.6.6
# Add the package.json and the package-lock.json to the container at /app
COPY package.json package-lock.json ./
# Install dependencies called out in the package.json
RUN npm install
# Add angular-cli karma and typescript configs to the container at /app
COPY .angular-cli.json karma.conf.js tsconfig.json tslint.json protractor.conf.js ./
# Add the app src to the container at /app/src
COPY src ./src
# Add the e2e tests to the container at /app/e2e
COPY e2e ./e2e
运行我的bash脚本时的命令行输出:
> webdriver-manager update --standalone false
[18:04:49] I/file_manager - creating folder /app/node_modules/protractor/node_modules/webdriver-manager/selenium
[18:04:56] I/update - chromedriver: unzipping chromedriver_2.37.zip
[18:04:56] I/update - chromedriver: setting permissions to 0755 for /app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.37
[18:05:01] I/update - geckodriver: unzipping geckodriver-v0.20.1.tar.gz
[18:05:01] I/update - geckodriver: setting permissions to 0755 for /app/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.20.1
chrome-response.xml gecko-response.json update-config.json
chromedriver_2.37 geckodriver-v0.20.1
chromedriver_2.37.zip geckodriver-v0.20.1.tar.gz
The option '--sauce' is not registered with the e2e command. Run `ng e2e --help` for a list of supported options.
** NG Live Development Server is listening on localhost:8100, open your browser on https://localhost:8100/ **
10% building modules 3/3 modules 0 activeGenerating SSL Certificate s
Date: 2018-04-12T18:05:18.269Z i Hash: b57e600f446f16a8f14c
Time: 13770ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 130 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 323 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 17.6 kB [initial] [rendered]
chunk {transactions.module} transactions.module.chunk.js, transactions.module.chunk.js.map () 1.17 MB [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.11 MB [initial] [rendered]
(node:31) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
webpack: Compiled successfully.
[18:05:18] I/update - chromedriver: file exists /app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.37.zip
[18:05:18] I/update - chromedriver: unzipping chromedriver_2.37.zip
[18:05:18] I/update - chromedriver: setting permissions to 0755 for /app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.37
[18:05:18] I/update - chromedriver: chromedriver_2.37 up to date
[18:05:18] I/launcher - Running 1 instances of WebDriver
[18:05:18] E/local - Error code: 135
[18:05:18] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[18:05:18] E/local - Error: No update-config.json found. Run 'webdriver-manager update' to download binaries.
答案 0 :(得分:0)
根本原因是角度cli ng e2e
将默认执行webdriver-manager update
。
您使用全局角度cli而非项目本地角色,因此它会尝试使用全局webdriver-manager
执行更新,但您没有安装全局webdriver-manager
,因此ng e2e
报告Error: No update-config.json found
。
解决问题的两个选项:
选项1 :添加webdriver-manager update
ng e2e
--wu false
COMMAND+=" && ng e2e --port 8100 --env test --sauce --wu false"
但是你需要自己更新webdriver,就像你到目前为止一样。
Option2 :通过删除-g
选项
# Install the Angular CLI globally
RUN npm install @angular/cli@1.6.6
答案 1 :(得分:0)
发现这是因为我没有使用独立版本的selenium(我不应该使用'--standalone false')。删除该行并在我的Dockerfile中安装java后,它就像一个梦想。