Skip to content

[🐛 Bug]: Running tests in parallel in docker causing tests to choose the wrong open window #15609

Open
@jonn-set

Description

@jonn-set

Description

I am running Selenium tests in parallel inside a Docker container (standalone-chrome) using the Surefire plugin. 80-90% of my tests fail and the screenshots captured in the After hook seem to indicate that a different test was running, like its querying a customer that is not part of thread the test is running in, etc., extremely difficult to put a finger on it and say what's wrong. I also see a lot of org.openqa.selenium.StaleElementReferenceException: stale element reference: stale element not found in the current frame. Which seems to indicate the test is trying to access the wrong open browser window.

I also use Spring and am using SimpleThreadScope() to create a 'thread' scope, the WebDriver & ScenarioContext are all marked as @Scope(scopeName = "thread") so I believe the configuration is correct as they all seem to work as expected in Windows on Edge, however when I run this in docker, it does not work.

My Project code base is very big and cant be shared on the forum, but I will try to create a separate project and share the link here, in the meantime if anyone notice anything obvious I am doing wrong, can they comment and let me know please.

Reproducible Code

These are the options I pass into the RemoteWebDriver Object when I build it:

--enable-automation
--disable-extensions
--disable-client-side-phishing-detection
--no-default-browser-check
--no-first-run
--enable-logging=stderr
--log-level=0
--headless
--disable-dev-shm-usage
--no-sandbox
--user-data-dir=/home/seluser/.config/google-chrome/default


I am starting Docker with the following parameters:

docker run -d \
    -p 4444:4444 \
    -v "$(pwd)"/uk-qa-race-ui/xml-files:/app/xml-files \
    --name selenium-chrome \
    --env SE_NODE_GRID_URL=http://localhost:4444 \
    --env SE_NODE_MAX_SESSIONS=4 \
    --env NODE_CONNECTION_LIMIT_PER_SESSION=4 \
    --env SE_NODE_OVERRIDE_MAX_SESSIONS=true \
	selenium-chrome


This is my Surefire config for parallel running of tests:

    <parallel>methods</parallel>
    <threadCountMethods>4</threadCountMethods>
    <perCoreThreadCount>false</perCoreThreadCount>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!B-gridEverything grid and server relatedC-javaJava BindingsD-chromeI-defectSomething is not working as intendedOS-linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions