4

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
jkinkead
  • 4,101
  • 21
  • 33

1 Answers1

1

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.

GensaGames
  • 5,538
  • 4
  • 24
  • 53
  • Thanks for the reply, but i manually coped chromedriver and gave the location to it like System.setProperty("webdriver.chrome.driver", webdriverPath); Seems the issue. the mail page loads, but whenever there is an authentication rerdirect flow to an exteral system, it is not returning back and giving this error **[0108/134327.972921:ERROR:cert_issuer_source_aia.cc(104)] AiaRequest::OnFetchCompleted got error -3 – Vijayakumar Kb Jan 12 '21 at 04:59
  • @VijayakumarKb this is completely different error from the description above. However you mentioned certificate issue, which should be disabled. Here is explanation https://stackoverflow.com/a/42340168/4133301 – GensaGames Jan 12 '21 at 05:03
  • i tried all those google-chrome --headless --no-sandbox '--disable-web-security' --disable-web-security --ignore-certificate-errors --ignore-ssl-error --dump-dom https://example.com but the page will redirect to a site with httpstatus 302, then loads a page with username passowrd. but i am not seeing that redirect page, only blank page. but if i load the redirect page directly it will load, but from the main home page it is not loading – Vijayakumar Kb Jan 12 '21 at 07:49
  • if i do curl -vk www.example.com from that docker host, it will return that 302, redirect url – Vijayakumar Kb Jan 12 '21 at 07:53
  • @VijayakumarKb Ok, that's fine. 302 it's ok result with redirect. What is the problem here? Probably you want to call url with redirects, for ex. `curl -L ` – GensaGames Jan 12 '21 at 08:15
  • yes curl -L works fine. But with selenium google chrome is not working. it just gives a blank page. – Vijayakumar Kb Jan 12 '21 at 11:36
  • @VijayakumarKb I don't understand you. This is completely different from the questions you have asked. Which username password login should be on example.com? Why it's example.com is not loading from the selenium? It's working just fine on my side? – GensaGames Jan 12 '21 at 21:04
  • sorry if i was not clear. Issues 1. I am running a headless chrome browser in docker and the page i request for eg : www.example.com on load redirects to a login page and on giving username and passwrd and click submit gets authenticated and comes back to www.example.com, if i do a curl -L on www.example.com it is working fine. but when i do the same using headless chrome browser it is not going to the authtication page with username and password, instead a blank page and test fails with element not found for username and password – Vijayakumar Kb Jan 13 '21 at 03:58
  • @VijayakumarKb Can you remove some of the options from your page above. 1. Try to run above chrome driver command WITHOUT `--ssl-protocol=TLSv1 --allow-running-insecure-content --allow-insecure-localhost` 2. Try also with `--enable-features=NetworkService` – GensaGames Jan 13 '21 at 05:21
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/227249/discussion-between-vijayakumar-kb-and-gensagames). – Vijayakumar Kb Jan 13 '21 at 05:57
  • @VijayakumarKb, I even faced a very similar problem what you had explained in your question. I tried and made it work. Details available in [https://stackoverflow.com/questions/66440432/robot-framework-test-case-fails-with-element-not-found-when-running-selenium-l]. Hope this helps you. – iamstuck Mar 07 '21 at 17:10