Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Advanced Selenium Example

info

This Workflows functionality is not available when running the Testkube Agent in Standalone Mode - Read More

Below is an advanced workflow for executing a Selenium test with maven and 3 browser engines; chrome, edge and firefox. The test itself is written in Java and available on GitHub. You can paste this directly into the YAML of an existing or new test, just make sure to update the name and namespace for your environment if needed.

  • The spec.content property defines the location of the GitHub project.
  • The spec.services property starts three services, one for each browser engine, which are then used to by Selenium when running the test (read more about Services).
  • The spec.steps property defines a single step that uses parallel to run the test for each browser engine and upload the created reports (read more about Parallel Execution).
  • The spec.steps[0].parallel.matrix property defines a matrix of ip-addresses gathered from the corresponding browser engine services (read more about Matrix Parameters).
  • The spec.steps[0].parallel.steps property defines the actual steps to run on each parallel node, using the properties defined in the matrix for the browser name and ip address.
Advanced Selenium Workflow
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: selenium-multiple-browser-parallel-test
namespace: testkube
spec:
content:
git:
uri: https://github.com/cerebro1/selenium-testkube.git
paths:
- selenium-java
services:
chrome:
logs: always
image: selenium/standalone-chrome:4.21.0-20240517
readinessProbe:
httpGet:
path: /wd/hub/status
port: 4444
periodSeconds: 1
edge:
logs: always
image: selenium/standalone-edge:4.21.0-20240517
readinessProbe:
httpGet:
path: /wd/hub/status
port: 4444
periodSeconds: 1
firefox:
logs: always
image: selenium/standalone-firefox:4.21.0-20240517
readinessProbe:
httpGet:
path: /wd/hub/status
port: 4444
periodSeconds: 1
steps:
- name: Run Cross-browser tests
parallel:
matrix:
browser:
- ip: '{{ services.chrome.0.ip }}'
name: chrome
- ip: '{{ services.firefox.0.ip }}'
name: firefox
- ip: '{{ services.edge.0.ip }}'
name: edge
transfer:
- from: /data/repo/selenium-java
fetch:
- from: /data/repo/selenium-java/target
to: /data/artifacts/{{ matrix.browser.name }}
container:
workingDir: /data/repo/selenium-java
image: maven:3.9.6-eclipse-temurin-22-alpine
steps:
- run:
env:
- name: SELENIUM_BROWSER
value: '{{ matrix.browser.name }}'
- name: SELENIUM_HOST
value: '{{ matrix.browser.ip }}:4444'
shell: |
mvn test
mvn surefire-report:report
- condition: always
workingDir: /data/artifacts
artifacts:
paths:
- '**/*'

After execution, you can see the output from the test executions under the executions panel tabs:

The log output from the Selenium execution with the second worker highlighted:

Selenium Log Output