Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

Getting empty page running selenium in headless chrome Docker

I am running a test cases in headless chrome inside an Oracle Linux based Docker.

The page I request should get redirected to an authentication page with the username password field, but I am getting blank page in the docker server(). This works fine from my macbook.

This is the output when i try do run the same directly using chrome browser from inside docker

bash-4.2# google-chrome --headless --no-sandbox  --dump-dom --ignore-ssl-errors --ignore-certificate-errors  --ssl-protocol=TLSv1 --allow-running-insecure-content --allow-insecure-localhost  https://example.com/

[0108/134257.881648:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

**[0108/134327.972921:ERROR:cert_issuer_source_aia.cc(104)] AiaRequest::OnFetchCompleted got error -3

**

OS Details : Linux 7e3f36f795d9 4.1.12-124.45.6.el7uek.x86_64 #2 SMP Wed Nov 25 06:46:51 PST 2020 x86_64 x86_64 x86_64 GNU/Linux

Even though I am running in linux docker, user agent passed is "--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36". Should I use a Linux user agent?

Chrome binary and Chrome webdriver version : 87.0.4280.88 What could be the reason for this, I am stuck in this for last 2 days. Thanks in Advance.

Docker file is as below

        FROM base_image
    ARG USER=usr
    RUN yum -y install wget 
    && wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm 
    && yum -y install libappindicator-gtk3-12.10.0-13.el7.x86_64  
    && yum -y install libXScrnSaver-1.2.2-6.1.el7.x86_64  
    && yum -y install liberation-fonts-1.07.2-16.el7.noarch 
    && yum -y install liberation-narrow-fonts-1.07.2-16.el7.noarch alsa-lib-1.1.8-1.el7.i686 xdg-utils alsa-lib-devel
    && wget     http://mirror.centos.org/centos/7/os/x86_64/Packages/vulkan-filesystem-1.1.97.0-1.el7.noarch.rpm 
    && wget http://mirror.centos.org/centos/7/os/x86_64/Packages/vulkan-1.1.97.0-1.el7.x86_64.rpm 
    && rpm -ivh vulkan-filesystem-1.1.97.0-1.el7.noarch.rpm 
    && rpm -ivh vulkan-1.1.97.0-1.el7.x86_64.rpm 
    && rpm -ivh google-chrome-stable_current_x86_64.rpm 
    && yum clean all
    RUN rm -rf /var/cache/yum;
    EXPOSE 8080

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So the problem in your docker image for sure. There are many thing happening in install and I don't see most obvious one with install of actual chromedriver.

# install chromedriver
RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/

More information about custom docker image you can check in this answer and thread. Furthermore I would suggest to go with prebuilt Selenium docker image which works perfectly every time for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.7k users

...