Error in pipeline maven with selenium driver chromedriver
Asked by Carmen Carrero:

Hello,  
I want to create a pipeline to execute a maven project. The project is with Selenium Java and the pipeline is the following:  

```
image: maven:3.9.1

pipelines:

 default:

   name: Execute tests

   trigger: automatic

   caches: 

         - maven

   script:

         - mvn clean install '-Dspring.profiles.active=${environmentName}' -DsuiteFileName=$testSuite -Dthreads=$threadsCount

   services:

          - selenium-chrome

definitions:

  services:

    selenium-chrome:

      image: selenium/standalone-chrome:3.141.59-oxygen
```

However, when I execute this pipeline appears the following error:  

    /root/.m2/repository/webdriver/chromedriver/linux64/114.0.5735.90/chromedriver: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory

I have tried a lot of things, and nothing changes... any help, please?


Answers:
author: Saxea _Flowie_
body: Very likely because \`chromedriver\` runs inside the \`maven:3.9.1\` image, which doesn't have the required dependencies. So you need to install them, or can use an image that has both mvn/chromedriver - you could try this one for instance: <https://hub.docker.com/r/markhobson/maven-chrome/>  

Similar issue here -\> <https://community.atlassian.com/t5/Bitbucket-questions/How-to-get-chromedriver-working-in-pipelines/qaq-p/1290531>

comments: author: Carmen Carrero
body: Hello!

First of all, thank you for commenting and sorry for taking so long to reply... I am still stuck on this.

I have created my own image Docker with Maven 3.9.1, Java 17, ChromeDriver 120 and Chrome 120. In my local, everthing works fine but in pipeline not. I think is due to execute Chrome inside a container. Here is my Dockerfile:

```
# Utiliza la imagen base de Ubuntu
FROM ubuntu:latest

# Actualiza los repositorios e instala herramientas b?sicas
RUN apt-get update && \
apt-get install -y wget unzip gnupg xvfb dbus-x11

# Descarga e instala el navegador Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome-archive-keyring.gpg && \
echo 'deb [signed-by=/usr/share/keyrings/google-chrome-archive-keyring.gpg arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/google-chrome.list && \
apt-get update && \
apt-get install -y google-chrome-stable

#Chromedriver
RUN wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.159/linux64/chromedriver-linux64.zip -P /tmp && \
unzip /tmp/chromedriver-linux64.zip -d /usr/local/bin && \
rm /tmp/chromedriver-linux64.zip

#Mover Chromediver
RUN mkdir -p /root/.m2/repository/webdriver/chromedriver/linux64/114.0.5735.90/ && \
mv /usr/local/bin/chromedriver-linux64/* /root/.m2/repository/webdriver/chromedriver/linux64/114.0.5735.90/

# Descarga e instala OpenJDK 17
RUN apt-get install -y openjdk-17-jdk

# Descarga e instala Maven 3.9.1
RUN wget https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.tar.gz -P /tmp && \
tar xf /tmp/apache-maven-3.9.1-bin.tar.gz -C /opt && \
ln -s /opt/apache-maven-3.9.1 /opt/maven && \
ln -s /opt/maven/bin/mvn /usr/local/bin/mvn && \
rm /tmp/apache-maven-3.9.1-bin.tar.gz

# Establece las variables de entorno para Maven y Java
ENV MAVEN_HOME /opt/maven
ENV MAVEN_CONFIG /root/.m2
ENV PATH "$PATH:/opt/maven/bin"
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64
ENV PATH "$PATH:$JAVA_HOME/bin"

ENV DISPLAY=:99
RUN Xvfb :99 -screen 0 1920x1080x24 -ac > /dev/null 2>&1 &
```

Here is my pipeline:

```
image: carmeneoris/selenium-maven:selenium

pipelines:
  default:
    - step:
      name: Execute tests
      trigger: automatic
      script:
        - mvn clean install -X '-Dspring.profiles.active=${environmentName}' -DsuiteFileName=$testSuite -Dthreads=$threadsCount
```

<br />

<br />

And here is the error when pipeline executes the command mvn clean install...:

    org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: exited normally.
    (session not created: DevToolsActivePort file doesn't exist)
    (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) 


Tags: bitbucket-cloud

cloud