Cant start browser on docker image

Hello

I have created a new image dockerfile but i have some issue to start my test on drivers
Could you please provide solution
Thank you

Use the official Ubuntu as the base image

FROM ubuntu:latest

Set environment variables to avoid interactive prompts during installation

ENV DEBIAN_FRONTEND=noninteractive

Install necessary dependencies, including wget

RUN apt-get update && apt-get install -y
python3.10
python3-pip
unzip
wget
libnss3
libatk-bridge2.0-0
libatspi2.0-0
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update -qq && apt-get install -y -qq
software-properties-common
apt-transport-https
wget \

Additional packages

&& apt-get clean
&& rm -rf /var/lib/apt/lists/*

Edge Installation

RUN wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | apt-key add -
RUN add-apt-repository “deb [arch=amd64] Index of /repos/edge/ stable main”
RUN apt install -y microsoft-edge-stable
RUN microsoft-edge --version
RUN which microsoft-edge

Download and install Microsoft Edge WebDriver

RUN wget -q https://msedgedriver.azureedge.net/118.0.2088.69/edgedriver_linux64.zip
&& unzip -q edgedriver_linux64.zip
&& chmod +x msedgedriver
&& mv msedgedriver /usr/local/bin

Verify msedgedriver installation

RUN msedgedriver --version

Upgrade pip and install required Python packages

RUN pip3 install --upgrade pip &&
pip3 install
robotframework==4.1.3
robotframework-seleniumlibrary==5.1.3
selenium==4.2.0

ENV PATH=$PATH:/usr/local/bin:/usr/bin/microsoft-edge:/usr/local/bin/msedgedriver

Install Chrome and Geckodriver

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo “deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google-chrome.list
&& apt-get update
&& apt-get install -f -y google-chrome-stable
chromium-browser
firefox
xvfb \

&& wget -q -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
&& tar -C /usr/local/bin -xzf /tmp/geckodriver.tar.gz
&& chmod 0755 /usr/local/bin
&& cd /usr/local/bin
&& ls
&& rm /tmp/geckodriver.tar.gz
&& cd /tmp \

&& wget https://chromedriver.storage.googleapis.com/114.0.5735.16/chromedriver_linux64.zip
&& unzip chromedriver_linux64.zip
&& rm -rf chromedriver_linux64.zip
&& mv -f chromedriver /usr/local/bin/chromedriver
&& chmod 0755 /usr/local/bin/chromedriver
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /usr/share/doc
/usr/share/man*
/tmp/*
/var/tmp/*

Clean up

RUN apt-get clean &&
rm -rf /var/lib/apt/lists/*

running test with edge gives

SessionNotCreatedException: Message: session not created: Microsoft Edge failed to start: exited normally.

105 (session not created: DevToolsActivePort file doesn’t exist)

106 (The process started from msedge location /usr/bin/google-chrome is no longer running, so msedgedriver is assuming that msedge has crashed.)

running test with chrome gives

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114

110Current browser version is 118.0.5993.117 with binary path /usr/bin/google-chrome

running test with gecko gives

WebDriverException: Message: Process unexpectedly closed with status 1

These are fairly old versions. Not sure how SeleniumLibrary v5.1.3 will handle the latest version of Edge. Any reasons for keeping these older versions?

1 Like

I will use the latest version
And maybe need to update the full test repository then
Could you share a working script to run edge browser in case my existing keyword is not working

Thanks
I will update you

Hi @Ultra,

I don’t see a Display? The browsers (Chrome and Firefox for sure, Edge probably) need a display even when running headless.

A simple way to deal with this docker containers, VM’s, etc is install XVFB, then configure the port it runs on, and use that same port number when configuring your DISPLAY variable.

Hope that helps,

Dave.

2 Likes

Hey… will you please provide me the Dockerfile for msedge that can run smoothly .
I need it

Not mine, but here’s an example → eficode/robotframework-selenium

If you check the docker file for either Chrome or Firefox, you’ll see xvfb is installed as a dependency and run as part of entry_point.sh

Dave.

Thanx @damies13

1 Like

@Abhigupta123 @damies13 Could you please let me know if you are able to solve this issue ? I am struggling from last three days to solve the problem

@damies13 @Abhigupta123 Are you able to solve issue . Is it possible to share the docker file ?