Foto von ThisIsEngineering: https://www.pexels.com/de-de/foto/ingenieur-halt-saubere-energiebatterie-3861437/

Using Selenium within Github Actions

Setting up the Chrome Driver

ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--no-sandbox");
options.addArguments("--disable-extensions");
options.addArguments("--disable-gpu");
WebDriver driver = new ChromeDriver(options);

Configuring the Github Action Pipeline

name: Selenium Example on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Setup Selenium
run: |
sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - && \
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \
sudo apt-get -y update && \
sudo apt-get install -y google-chrome-stable && \
sudo apt-get install -yqq unzip && \
sudo wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip && \
sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/ && \
DISPLAY=:99 && \
sudo apt install -y python3-pip && \
sudo pip install --upgrade pip && \
sudo pip install selenium
- name: Build with Maven
run: cd my-selenium-app && mvn -DskipTests -B package --file pom.xml
- name: Execute Selenium app
run: cd my-selenium-app && java -jar target/my-selenium-app.jar update-index-flatfox

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aymen Furter

I am a Cloud Solution Architect working for Microsoft. The views expressed on this site are mine alone and do not necessarily reflect the views of my employer.