在本地运行selenium测试时,它会自动打开chrome浏览器来执行任务。但是,虽然从docker运行相同的命令却没有,但测试失败并出现以下错误。
未知错误:无法集中元素
错误:处理命令时发生未知的服务器端错误。
kam-MBP: kl$ docker build -t dockerfinal .
Sending build context to Docker daemon 787.3MB
Step 1/3 : FROM dockerinit
---> 4d6fdb65d879
Step 2/3 : USER root
---> Using cache
---> 5fab69855211
Step 3/3 : RUN ./node_modules/.bin/wdio
---> Running in f55f142eabf3
------------------------------------------------------------------
[chrome #0-0] Session ID: 819c77057d6a7e274c8fbfd36858e3d9
[chrome #0-0] Spec: /tinderbox2_frontend/e2e/accproset.test.js
[chrome #0-0] Running: chrome
[chrome #0-0]
[chrome #0-0] accountprojectsetting
[chrome #0-0] 1) "before each" hook for "should be able to do setting in account and project"
[chrome #0-0]
[chrome #0-0]
[chrome #0-0] **1 failing (30s)**
[chrome #0-0]
[chrome #0-0] 1) accountprojectsetting "before each" hook for "should be able to do setting in account and project":
[chrome #0-0] **unknown error: cannot focus element**
[chrome #0-0] Error: An unknown server-side error occurred while processing the command.
[chrome #0-0] at elementIdValue("0.17283645604924724-1", "testG1BDCgRtwowtEBp@moxion.rocks") - setValue.js:46:80
我的 dockerinit 图片泊坞窗文件如下:
# setting base image
FROM selenium/standalone-chrome
USER root
# Set the working directory to /tin_fe
WORKDIR /tin_fe
#Access to the project within docker container - Bundle app source
COPY . /tin_fe
# Install Node.js
RUN apt-get update
RUN apt-get install --yes curl
#configuring nodeSource repository to get enough version of nodejs
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
RUN apt-get install -y nodejs
#configuring debian package repository
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
#installing yarn
RUN apt-get update && apt-get install -y yarn
#installing binary git package
RUN apt-get update
RUN apt-get install -y git
#running yarn
RUN yarn