Skip to content

Conversation

@mialeska
Copy link
Contributor

Update DevTools references to use V143 in tests

Update DevTools references to use V143 in tests
@mialeska mialeska self-assigned this Dec 30, 2025
@mialeska mialeska added enhancement New feature or request java labels Dec 30, 2025
@github-project-automation github-project-automation bot moved this to In progress in Aquality Selenium Dec 30, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

Walkthrough

Updated Maven dependency versions and advanced Selenium DevTools protocol imports; added new network emulation public APIs and test/fixture updates, plus small locator and test-constant adjustments. No public class signature removals.

Changes

Cohort / File(s) Change Summary
Build / Dependencies
pom.xml
Bumped dependencies: com.github.aquality-automation:aquality-selenium-core and org.apache.commons:commons-lang3 to newer versions.
DevTools import updates
src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java, src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java, src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java, src/test/java/tests/usecases/devtools/DeviceEmulationTest.java, src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java
Switched Selenium DevTools protocol imports to newer v142/v143 package paths; no logic changes.
NetworkHandling (API + implementation)
src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java, src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java
Added public methods: emulateConditionsByRule(Boolean, List<NetworkConditions>), overrideState(Boolean, Number, Number, Number), and overrideState(Boolean, Number, Number, Number, ConnectionType); added deprecated string-typed overload; tests refactored to use network() accessor and new helpers; updated imports to v143 Network types.
Form / Locator and cookie handling updates
src/test/java/forms/MyLocationForm.java, src/test/java/w3schools/forms/SelectMultipleForm.java
Updated element locators, added consent/cookie iframe handling and auto-consent flow in MyLocationForm; SelectMultipleForm now handles cookie iframe switching and updated locators.
Test constants and minor test changes
src/test/java/automationpractice/Constants.java, src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java
Changed test URL constant and rounded geolocation constants; no flow changes.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as Test Case
    participant Network as NetworkHandling
    participant DevTools as DevTools/CDP
    participant Browser as Browser (navigator/network)
    participant Page as Page/Form

    Note over Test,Network: New network emulation flow (high level)
    Test->>Network: emulateConditionsByRule(offline?, conditionsList)
    Network->>DevTools: send Network.emulateNetworkConditions / setNetworkState
    DevTools->>Browser: apply network metrics (latency, throughput, offline, connectionType)
    Browser->>Page: simulate network behavior on reload/request
    Page-->>Test: content load / timeout / error
    Note over Test,Network: Later: Network.overrideState(...) to explicitly set navigator state
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

dependencies

Poem

🐰 A little hop, a patch and a tweak,
New DevTools paths and networks to peek.
I sniff the locators, consent gets a click,
Tests refreshed, dependencies picked.
Hooray — the rabbit approves this quick fix!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title mentions updating to Selenium 4.39.0 but the actual changes include DevTools v143 updates, dependency upgrades (commons-lang3), and test locator fixes across multiple test files. Consider a more specific title such as 'Update Selenium to 4.39.0 and DevTools to v143' or 'Upgrade Selenium 4.39.0 with DevTools v143 and improve test locators' to better reflect the comprehensive scope of changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description 'Update DevTools references to use V143 in tests' is related to the changeset but only addresses one aspect of the changes (DevTools v143 updates) and misses other significant changes like dependency upgrades and test locator updates.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d71d3aa and d4e0fa8.

📒 Files selected for processing (1)
  • pom.xml

…e geolocation override test

Update DevTools references to use V143 in the library and V142 in tests
Update commons-lang3 reference
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 31, 2025

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (5)
src/test/java/w3schools/forms/SelectMultipleForm.java (1)

29-30: Verify the updated locators work with the current W3Schools UI.

The Accept Cookies locator has been updated to a more complex CSS selector, and a new iframe field has been added. These changes suggest W3Schools modified their cookie consent implementation. Please ensure the new locators correctly identify the elements on the current W3Schools page.

Optional: Consider the semantic accuracy of element types.

Using ILabel for an iframe element (line 30) is semantically incorrect, though it may work functionally. If the framework provides a more generic element type (e.g., IElement) or supports creating custom element interfaces, consider using a more appropriate type for iframe elements.

src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java (1)

28-29: Consider adding delta tolerance for floating-point comparisons.

Using Assert.assertEquals on double values without a delta tolerance may cause flaky tests if there's any floating-point representation variance. Consider using the overload with a tolerance parameter.

🔎 Proposed fix
-        Assert.assertEquals(form.getLatitude(), LAT_FOR_OVERRIDE);
-        Assert.assertEquals(form.getLongitude(), LNG_FOR_OVERRIDE);
+        Assert.assertEquals(form.getLatitude(), LAT_FOR_OVERRIDE, 0.000001, "Latitude override mismatch");
+        Assert.assertEquals(form.getLongitude(), LNG_FOR_OVERRIDE, 0.000001, "Longitude override mismatch");
src/test/java/forms/MyLocationForm.java (2)

14-16: Form locator is quite generic.

The locator //*[contains(text(),'Location')] is broad and may match unintended elements on pages with the word "Location" anywhere. Consider making it more specific if stability issues arise.


18-23: Side effect in getter - consider documenting or refactoring.

getLatitude() now has a side effect of clicking the consent button. This may surprise callers who expect a pure getter. Consider either:

  1. Adding a Javadoc comment explaining this behavior, or
  2. Moving consent handling to a dedicated method called from the test setup.
src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java (1)

359-361: Consider extracting the repeated enable() call.

Each method calls enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()). While this ensures network monitoring is active, consider extracting to a private helper for DRY and readability.

🔎 Proposed refactor
private void ensureNetworkEnabled() {
    tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
}

Then replace all occurrences with ensureNetworkEnabled();

Also applies to: 372-374, 386-388

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4e0fa8 and a8381e9.

📒 Files selected for processing (12)
  • pom.xml
  • src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java
  • src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java
  • src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java
  • src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java
  • src/test/java/automationpractice/Constants.java
  • src/test/java/forms/MyLocationForm.java
  • src/test/java/tests/usecases/devtools/DeviceEmulationTest.java
  • src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java
  • src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java
  • src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java
  • src/test/java/w3schools/forms/SelectMultipleForm.java
✅ Files skipped from review due to trivial changes (3)
  • src/test/java/tests/usecases/devtools/DeviceEmulationTest.java
  • src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java
  • src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: mialeska
Repo: aquality-automation/aquality-selenium-java PR: 148
File: src/test/java/tests/usecases/devtools/DeviceEmulationTest.java:6-7
Timestamp: 2024-11-29T14:35:07.825Z
Learning: In this project, the use of custom DevTools Protocol version (v131) in test files is intentional, even if it differs from the version used in the main source code.
Learnt from: mialeska
Repo: aquality-automation/aquality-selenium-java PR: 150
File: src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java:121-121
Timestamp: 2025-05-28T19:55:33.768Z
Learning: The DevTools v137 `Emulation.setDeviceMetricsOverride` method has 14 parameters, not 13 as some documentation might suggest. Recent versions of the Selenium DevTools API have added additional parameters to this method.
📚 Learning: 2024-11-29T14:35:07.825Z
Learnt from: mialeska
Repo: aquality-automation/aquality-selenium-java PR: 148
File: src/test/java/tests/usecases/devtools/DeviceEmulationTest.java:6-7
Timestamp: 2024-11-29T14:35:07.825Z
Learning: In this project, the use of custom DevTools Protocol version (v131) in test files is intentional, even if it differs from the version used in the main source code.

Applied to files:

  • src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java
  • src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java
📚 Learning: 2025-05-28T19:55:33.768Z
Learnt from: mialeska
Repo: aquality-automation/aquality-selenium-java PR: 150
File: src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java:121-121
Timestamp: 2025-05-28T19:55:33.768Z
Learning: The DevTools v137 `Emulation.setDeviceMetricsOverride` method has 14 parameters, not 13 as some documentation might suggest. Recent versions of the Selenium DevTools API have added additional parameters to this method.

Applied to files:

  • src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java
  • src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java
🧬 Code graph analysis (2)
src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java (1)
src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java (1)
  • NetworkHandling (31-410)
src/test/java/w3schools/forms/SelectMultipleForm.java (1)
src/main/java/aquality/selenium/browser/AqualityServices.java (1)
  • AqualityServices (16-176)
🔇 Additional comments (14)
src/test/java/w3schools/forms/SelectMultipleForm.java (2)

6-6: LGTM!

The new imports are necessary for the updated cookie acceptance flow that handles iframe context switching.

Also applies to: 21-21


37-45: LGTM!

The updated acceptCookies method correctly handles the iframe context for W3Schools' cookie consent UI. The logic:

  • Conditionally switches to the iframe if it exists
  • Waits for and clicks the Accept button
  • Always ensures we're back in default content
  • Waits for the iframe to disappear after acceptance

This gracefully handles both scenarios where the iframe exists or doesn't exist.

src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java (1)

15-17: LGTM!

The DevTools imports are correctly updated to v143, and all usages (Page.removeScriptToEvaluateOnNewDocument, ScriptIdentifier, Runtime.addBinding, Runtime.removeBinding, Runtime.enable) are consistent with the new protocol version.

src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java (1)

5-8: LGTM!

The DevTools imports are correctly updated to v143 for RGBA, Emulation, MediaFeature, and ScreenOrientation. The existing usage patterns, including the 14-parameter setDeviceMetricsOverride call, remain compatible with the updated protocol version. Based on learnings, this parameter count is expected for recent DevTools versions.

src/test/java/tests/usecases/devtools/OverrideGeolocationTest.java (1)

13-14: LGTM - values adjusted for new test site.

The geolocation override constants are appropriately rounded to 6 decimal places, which aligns with typical geolocation API precision.

src/test/java/forms/MyLocationForm.java (1)

10-12: LGTM - Flexible locators for the new test site.

The union XPath expressions provide good fallback strategies for different page layouts. The consent button locator handles both aria-label and class-based selectors appropriately.

src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java (2)

25-29: LGTM - Good refactoring with helper methods.

Extracting network() helper and moving WelcomeForm to a field improves readability and reduces duplication.


46-55: LGTM - Test correctly uses new network emulation APIs.

The test properly combines emulateConditionsByRule and overrideState as documented in the NetworkHandling class, replacing the deprecated emulateConditions method.

src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java (4)

11-11: LGTM - Network model imports updated to v143.

The wildcard import for org.openqa.selenium.devtools.v143.network.model.* is consistent with the DevTools version upgrade.


341-349: LGTM - Appropriate deprecation with migration guidance.

The deprecation annotation and Javadoc clearly direct users to the new emulateConditionsByRule and overrideState methods. The method remains functional for backward compatibility.


351-362: LGTM - New emulateConditionsByRule API.

The new method properly documents the difference from the deprecated approach: it affects individual requests via URL matching without modifying navigator state.


364-389: LGTM - New overrideState APIs with clear purpose.

Both overloads correctly implement navigator state override functionality. The 5-parameter version with ConnectionType provides fine-grained control.

src/test/java/automationpractice/Constants.java (1)

8-8: URL change is verified and stable.

The new geolocation test URL https://whereamirightnow.org is accessible with HTTP/2 200 response and proper server headers. The constant is used only in OverrideGeolocationTest.java for its intended purpose.

pom.xml (1)

78-78: The upgrade to commons-lang3 3.20.0 successfully resolves CVE-2025-48924.

This is a valid release (November 12, 2025) that addresses the uncontrolled-recursion vulnerability in ClassUtils.getClass() which affected versions 3.0 through 3.17.x. No new vulnerabilities are known for version 3.20.0.

@mialeska mialeska merged commit c255e20 into master Dec 31, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Aquality Selenium Dec 31, 2025
@mialeska mialeska deleted the enhancement/update-to-selenium-4.39.0 branch December 31, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants