Skip to content

Update DevTools Network.setCookie call to Selenium v148 signature in JUnit5 test#418

Merged
diemol merged 2 commits into
mainfrom
copilot/fix-setcookie-signature
May 29, 2026
Merged

Update DevTools Network.setCookie call to Selenium v148 signature in JUnit5 test#418
diemol merged 2 commits into
mainfrom
copilot/fix-setcookie-signature

Conversation

Copilot AI commented May 29, 2026

Copy link
Copy Markdown
Contributor

CI for PR #417 fails at test compilation because DevToolsTest#setCookie calls org.openqa.selenium.devtools.v148.network.Network.setCookie(...) with an outdated argument list. This change aligns the test with the current v148 API while preserving the existing cookie setup/assert behavior.

  • What changed

    • Updated selenium-junit5-examples/src/test/java/com/saucedemo/selenium/selenium_features/DevToolsTest.java
    • In setCookie(), removed the obsolete trailing Optional.empty() argument from Network.setCookie(...)
  • Behavior preserved

    • Still sets cookie cheese=gouda for www.selenium.dev
    • Still verifies cookie value after navigation
  • Code change (excerpt)

    devTools.send(
        Network.setCookie(
            "cheese",
            "gouda",
            Optional.empty(),
            Optional.of("www.selenium.dev"),
            Optional.empty(),
            Optional.of(true),
            Optional.empty(),
            Optional.empty(),
            Optional.empty(),
            Optional.empty(),
            Optional.empty(),
            Optional.empty(),
            Optional.empty()));
Original prompt

Fix the failing GitHub Actions job for PR #417 in repository saucelabs-training/demo-java.

The failure is in the workflow job from run 26542692689, job 78236992997, where Maven test compilation fails in:

  • selenium-junit5-examples/src/test/java/com/saucedemo/selenium/selenium_features/DevToolsTest.java

The specific compile error is that org.openqa.selenium.devtools.v148.network.Network.setCookie(...) is being called with an outdated argument list. The current Selenium DevTools v148 API expects a shorter signature, but the test currently passes 14 arguments.

Please update the setCookie() test method to use the current Network.setCookie signature expected by Selenium DevTools v148 so that the project compiles again.

Relevant details:

  • Workflow file: .github/workflows/selenium-junit5-examples.yml
  • The failing code is in the setCookie test around line 102.
  • Keep the behavior of the test the same: set a cookie named cheese with value gouda for www.selenium.dev, then verify the cookie value after navigation.
  • Prefer a minimal change.
  • If needed, make Optional.empty() calls explicit to avoid generic type inference issues.

Please create a pull request with the fix.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is a compile-time API mismatch in DevToolsTest.setCookie() at line 102 of selenium-junit5-examples/src/test/java/com/saucedemo/selenium/selenium_features/DevToolsTest.java:
https://github.com/saucelabs-training/demo-java/blob/6028ffbc2291cf2aed19c349a547baa5420c5665/selenium-junit5-examples/src/test/java/com/saucedemo/selenium/selenium_features/DevToolsTest.java

Root cause

The workflow runs mvn test on Java 21 in .github/workflows/selenium-junit5-examples.yml:
https://github.com/saucelabs-training/demo-java/blob/6028ffbc2291cf2aed19c349a547baa5420c5665/.github/workflows/selenium-junit5-examples.yml

Network.setCookie(...) in Selenium DevTools v148 no longer matches the older argument list used in the test. The compiler error shows the current method expects 8 parameters, but the code is passing 14 parameters, with several Optional.empty() values inferred as Optional<Object>.

Fix

Update the call to match the current org.openqa.selenium.devtools.v148.network.Network.setCookie signature.

Replace this block in DevToolsTest.java:

devTools.send(
    Network.setCookie(
        "cheese",
        "gouda",
        Optional.empty(),
        Optional.of("www.selenium.dev"),
        Optional.empty(),
        Optional.of(true),
        Optional.empty(),
        Optional.empty(),
        Optional.empty(),
        Optional.empty(),
        Optional.empty(),
        Optional.empty(),
        Optional.empty(),
        Optional.empty()));

with:

devTools.send(
    Network.setCookie(
        "cheese",
        "gouda",
        Optional.empty(),
        Optional.of("www.selenium.dev"),
        Optional.empty(),
        Optional.of(true),
        Optional.empty(),
        Optional.empty()));

Why this works

The current v148 API expects:

setCookie(
    String name,
    String value,
    Optional<String> url,
    Optional<String> domain,
    Optional<String> path,
    Optional<Boolean> secure,
    Optional<Boolean> httpOnly,
    Optional<CookieSameSite> sameSite)

Your current code is using an older, longer signature that no longer exists in this Selenium version.

Optional improvement

To avoid type inference issues with Optional.empty(), you can make the empty optionals explicit:

devTools.send(
    Network.setCookie(
        "cheese",
        "gouda",
        Optional.<String>empty(),
        Optional.of("www.selenium.dev"),
        Optional.<String>empty(),
        Optional.of(true),
        Optional.<Boolean>empty(),
        Optional.empty()));

Summary

This is not a workflow problem; the workflow is correctly running the JUnit 5 module. The fix is to update DevToolsTest.setCookie() to the current Selenium DevTools v148 setCookie method signature by removing the obsolete extra arguments.

User: Can you create a PR that implements that fix?

Assistant: I’ve prepared the PR creation request and we’re just waiting for your confirmation in the GitHub prompt before I can continue.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix outdated argument list for setCookie in DevToolsTest Update DevTools Network.setCookie call to Selenium v148 signature in JUnit5 test May 29, 2026
Copilot finished work on behalf of diemol May 29, 2026 08:52
Copilot AI requested a review from diemol May 29, 2026 08:52
@diemol diemol marked this pull request as ready for review May 29, 2026 09:07
@diemol diemol merged commit 0806b34 into main May 29, 2026
1 of 2 checks passed
@diemol diemol deleted the copilot/fix-setcookie-signature branch May 29, 2026 09:07
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.

2 participants