我正在尝试使用官方的jenkins码头工人镜像来设置jenkins。
Dockerfile
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt install -y ruby-full
RUN apt-get install -y curl
RUN apt -y autoremove
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
RUN apt install -y wget
RUN gem install --no-ri --no-rdoc --format-executable rake
RUN gem install selenium-webdriver
RUN gem install bundler
RUN npm install -g node-mongo-seeds
#Permissions granted to jenkins user to do a gem install
RUN chown -R jenkins:jenkins /var/lib/gems
RUN apt-get install -y patch ruby-dev zlib1g-dev liblzma-dev
RUN chown -R jenkins:jenkins /usr/local/bin
# We need wget to set up the PPA and xvfb to have a virtual screen and unzip to install the Chromedriver
RUN apt-get install -y wget xvfb unzip
# Set up the Chrome PPA
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
# Update the package list and install chrome
RUN apt-get update -y
RUN apt-get install -y google-chrome-stable
# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 2.35
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
# Put Chromedriver into the PATH
ENV PATH $CHROMEDRIVER_DIR:$PATH
USER jenkins
在运行作业时,浏览器将无法打开并进入本地主机。 我也尝试点击“ google.com”
google-chrome --headless --no-sandbox 'https://www.google.com'
仍然没有成功
Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[0531/130727.949511:ERROR:browser_process_sub_thread.cc(217)] Waited 17 ms for network service
我不明白为什么jenkins用户无法打开浏览器。
答案 0 :(得分:1)
因此,按照@DebanjanB的注释,它解决了驱动程序问题,但是根据新的chrome崩溃问题,我只添加了
就解决了options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
d = Selenium::WebDriver.for :chrome, options: options
答案 1 :(得分:0)
此错误消息...
unknown error: Chrome failed to start: crashed (Selenium::WebDriver::Error::UnknownError)
...表示 ChromeDriver 无法启动/产生新的 WebBrowser ,即 Chrome浏览器会话。
您的主要问题是所使用的二进制版本之间的不兼容性:
支持 Chrome v62-64
支持 Chrome v74
因此 ChromeDriver v2.35 与 Chrome浏览器v74.0
之间存在明显的不匹配@Test
。