Skip to content

Allow tests to pass extra Chrome arguments to @InjectWebDriver - #54145

Open
trixpan wants to merge 1 commit into
keycloak:mainfrom
trixpan:issue-54144-webdriver-chrome-arguments
Open

trixpan wants to merge 1 commit into
keycloak:mainfrom
trixpan:issue-54144-webdriver-chrome-arguments

Conversation

@trixpan

@trixpan trixpan commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Closes #54144

Part of the test-framework preparation for #42257.

Summary

  • Add per-test chromeArguments to @InjectWebDriver.
  • Pass the arguments to Chrome and Chrome Headless after the framework defaults.
  • Prevent WebDriver instances requested with different Chrome arguments from being shared.
  • Document the annotation option and add unit and real-browser coverage.

Chrome-specific arguments are ignored by other browser implementations.

Testing

  • KC_TEST_BROWSER=chrome-headless ./mvnw package -f test-framework/pom.xml -Dtest=DriverOptionsTest,WebDriverChromeArgumentsTest -DfailIfNoTests=false
  • ./mvnw package -f test-framework/pom.xml
  • ./mvnw spotless:check -pl test-framework/ui,test-framework/tests

AI assistance

This PR was developed with assistance from Claude Opus and OpenAI Codex. I reviewed and understand the submitted changes.

@trixpan
trixpan requested a review from a team as a code owner October 20, 2026 02:47
Copilot AI balanced review requested due to automatic review settings October 20, 2026 02:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes preserve defaults, propagate Chrome arguments correctly, and leave no identified blocking issues.

No open issues 🎉

What changed in this PR

Adds per-test Chrome arguments to the test framework, preparing for Device Bound Session Credentials coverage without changing global browser defaults.

Changes:

  • Applies annotation arguments after defaults for Chrome and Chrome Headless.
  • Prevents driver sharing when requested arguments differ.
  • Adds documentation, unit tests, and real-browser coverage.
File Description
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​HtmlUnitWebDriverSupplier.java Disambiguates the null overload call.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​DriverUtils.java Forwards extra Chrome arguments.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​DriverOptions.java Appends arguments after defaults.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​ChromeWebDriverSupplier.java Uses annotation arguments for Chrome.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​ChromeHeadlessWebDriverSupplier.java Uses annotation arguments for headless Chrome.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​AbstractWebDriverSupplier.java Passes annotations and checks argument compatibility.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​annotations/​InjectWebDriver.java Declares the chromeArguments option.
test-framework/​tests/​src/​test/​java/​org/​keycloak/​testframework/​ui/​webdriver/​DriverOptionsTest.java Tests argument ordering and unchanged defaults.
test-framework/​tests/​src/​test/​java/​org/​keycloak/​testframework/​tests/​WebDriverChromeArgumentsTest.java Verifies arguments affect a Chrome session.
test-framework/​docs/​WRITING_TESTS.md Documents usage and driver-sharing behavior.

Review effort: Balanced

Expose per-test Chrome arguments through the WebDriver injection annotation, apply them to Chrome and Chrome Headless sessions, and keep drivers with different arguments isolated.

Closes keycloak#54144

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
Signed-off-by: Andre F de Miranda <trixpan@users.noreply.github.com>
@trixpan
trixpan force-pushed the issue-54144-webdriver-chrome-arguments branch from 0483197 to 47c3947 Compare November 26, 2026 23:03
Copilot AI balanced review requested due to automatic review settings November 26, 2026 23:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The added tests do not cover argument-based WebDriver isolation, leaving compatible reuse and prevention of argument leakage unverified for the same ref with equal, different, and empty versus nonempty argument arrays.

1 open issue

Review effort: Balanced

public boolean compatible(InstanceContext<ManagedWebDriver, InjectWebDriver> a, RequestedInstance<ManagedWebDriver, InjectWebDriver> b) {
return a.getAnnotation().ref().equals(b.getAnnotation().ref());
return a.getAnnotation().ref().equals(b.getAnnotation().ref())
&& Arrays.equals(a.getAnnotation().chromeArguments(), b.getAnnotation().chromeArguments());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow per-test Chrome arguments with @InjectWebDriver

2 participants