I have a React project with a Java Selenium e2e test suite in the same repo and I am using GitHub Actions for a CI pipeline to run the tests on push or PR to main. The tests all pass when I run them either on the deployed app on Render or running on localhost. The CI pipeline also works perfectly when tests are set to run on the deployed app but the CI pipeline tests won’t connect when set to test the app running locally on localhost.
Projects2ColumnsTest > testPresenceOfBurgerBarMenu() FAILED
org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
(Session info: chrome-headless-shell=124.0.6367.60)
Build info: version: '4.15.0', revision: '1d14b5521b'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.5.0-1018-azure', java.version: '17.0.11'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [a1d60a462e51376719f65ce4cfea26e4, get {url=http://127.0.0.1:5173/}]
Capabilities {acceptInsecureCerts: false, browserName: chrome-headless-shell, browserVersion: 124.0.6367.60, chrome: {chromedriverVersion: 124.0.6367.207 (a9001a6e39f..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:33853}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:cdp: ws://localhost:33853/devtoo..., se:cdpVersion: 124.0.6367.60, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
I doubt the Java is very useful as the tests all run fine locally. The CI workflow is:
name: e2e automation tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update Chrome to latest version
run: |
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Run e2e automation tests
working-directory: e2e
run: ./gradlew build
- name: Upload Selenium screenshots
uses: actions/upload-artifact@v3
if: always()
with:
name: screenshots
path: /home/runner/work/portfolio-react/portfolio-react/e2e/app/screenshots/
Please ask if any more details would be useful.
The same tests in the same situation all pass when run locally in terminal.
I have also tried changing the URL to 127.0.0.1 and even a local IP for my machine.
I can reach the site in Chrome for all URLs tried but each fails in the CI tests with the same error.
I am very new to Java, Selenium, CI and yaml.