Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98894

Executing Selenium test on Docker container within Jenkins Blue Ocean

$
0
0

I'm trying to run a basic Selenium GUI test on Jenkins Blue Ocean, which I have running locally from a Docker container. My process is to:

  • Start up a Docker Linux container within Jenkins where the script will run
  • Download any dependencies I need to that Docker container
  • Run my Selenium tests

I've tried multiple iterations of setting installing Firefox and Geckodriver, but keep getting the error

HOOK-ERROR in before_tag(tag=WebDriver): WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

I'm extracting geckodriver to /usr/bin and making it executable. However, if I log on to the container where the build is being executed, it doesn't seem to ge recognized. Running geckodriver -v gives the error bash: /usr/bin/geckodriver: No such file or directory, even if I am in the same directory as geckodriver. Any ideas whats going wrong?

Here is my Dockerfile

FROM alpine:latest

RUN apk add python3
RUN apk add firefox-esr


# Install Gecko Driver
ENV GECKODRIVER_VERSION 0.26.0
ENV BIT 64
ENV DOWNLOAD_URL https://github.com/mozilla/geckodriver/releases/download/v${GECKODRIVER_VERSION}/geckodriver-v${GECKODRIVER_VERSION}-linux${BIT}.tar.gz
RUN wget ${DOWNLOAD_URL}
RUN tar -xzvf geckodriver-v${GECKODRIVER_VERSION}-linux${BIT}.tar.gz
RUN chmod 755 geckodriver
RUN cp geckodriver /usr/bin/.
RUN rm geckodriver*

And here is my Jenkinsfile

pipeline {
    agent {
        dockerfile true
    }
    stages {
        stage("Prepare") {
            steps {
                sh """
                export PATH=$PATH:/usr/bin
                pip3 install -r requirements.txt
                """
            }
        }
        stage("Test") {
            steps {
                sh """
                export PATH=$PATH:/usr/bin
                python3 execute.py
                """
            }
        }
    }
    post {
        always {
            junit "junit/*.xml"
        }
    }
}

Viewing all articles
Browse latest Browse all 98894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>