Skip to content

[CUS-10952] ADDED NLP FOR MOBILE WEB APPLICATION.#348

Open
ManojTestsigma wants to merge 1 commit intodevfrom
CUS-10952
Open

[CUS-10952] ADDED NLP FOR MOBILE WEB APPLICATION.#348
ManojTestsigma wants to merge 1 commit intodevfrom
CUS-10952

Conversation

@ManojTestsigma
Copy link
Copy Markdown
Contributor

@ManojTestsigma ManojTestsigma commented Feb 27, 2026

please review this addon and publish as PUBLIC

Addon name : MOCK_GEO_LOCATION
Addon accont: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira: https://testsigma.atlassian.net/browse/CUS-10952

fix

Summary by CodeRabbit

  • New Features
    • Added geolocation mocking for mobile web tests. Override device location with custom latitude, longitude, and accuracy values to test location-dependent features across different scenarios. Includes input validation and detailed error feedback for troubleshooting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

A new MockGeoLocationAction class is introduced for mobile web testing, enabling geolocation override functionality. The implementation validates latitude, longitude, and accuracy inputs, then applies them via Chrome DevTools with cascading fallbacks to CDP mechanisms if initial attempts fail.

Changes

Cohort / File(s) Summary
New Geolocation Mock Action
mock_geo_location/src/main/java/com/testsigma/addons/mobileweb/MockGeoLocationAction.java
New action class implementing geolocation override using Chrome DevTools Emulation.setGeolocationOverride command with fallback to CDP executeCdpCommand. Includes input validation for latitude, longitude, and accuracy parameters with comprehensive error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Framework
    participant Action as MockGeoLocationAction
    participant WebDriver as WebDriver/ChromiumDriver
    participant DevTools as Chrome DevTools
    participant CDP as CDP Command Handler

    Test->>Action: execute() with lat, long, accuracy
    Action->>Action: Validate inputs (numeric, accuracy ≥ 0)
    
    alt Validation Success
        Action->>Action: Build geolocation payload
        Action->>DevTools: Attempt DevTools session
        
        alt DevTools Available
            Action->>DevTools: Send Emulation.setGeolocationOverride
            DevTools-->>Action: Command executed
            Action-->>Test: RESULT.SUCCESS
        else DevTools Unavailable
            Action->>WebDriver: Check for CDP support (HasCdp/ChromiumDriver)
            
            alt HasCdp Available
                WebDriver->>CDP: executeCdpCommand(Emulation.setGeolocationOverride)
                CDP-->>WebDriver: Command executed
                WebDriver-->>Action: Success
                Action-->>Test: RESULT.SUCCESS
            else CDP via Reflection
                Action->>WebDriver: executeCdpCommand via RemoteWebDriver reflection
                WebDriver->>CDP: Execute command
                CDP-->>WebDriver: Command executed
                WebDriver-->>Action: Success
                Action-->>Test: RESULT.SUCCESS
            end
        end
    else Validation Failed
        Action->>Action: Log error details
        Action-->>Test: RESULT.FAILED with error message
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 Whiskers twitch with glee, coordinates take flight,
DevTools dance and CDP glows bright,
Latitude and longitude now blessed,
Geolocation mocking puts browsers to the test!
Fallbacks ensure no location's left behind,
Error handling keeps chaos confined! 🗺️✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title '[CUS-10952] ADDED NLP FOR MOBILE WEB APPLICATION' does not accurately describe the change; the PR introduces a MockGeoLocationAction class, not NLP functionality. Revise the title to reflect the actual change, such as '[CUS-10952] Add MockGeoLocationAction for mobile web geolocation override' or similar.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch CUS-10952

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@mock_geo_location/src/main/java/com/testsigma/addons/mobileweb/MockGeoLocationAction.java`:
- Around line 105-116: The reflection-based RemoteWebDriver fallback in
MockGeoLocationAction (the block using
RemoteWebDriver.class.getDeclaredMethod("execute", ...) and invoking
"executeCdpCommand") is non-functional for CDP; remove this reflection hack and
replace it with clear error handling: detect lack of CDP support (check for
instances of HasCdp or ChromiumDriver earlier) and when neither is available
throw or log a descriptive UnsupportedOperationException/RuntimeException that
includes the driver class name and a message that CDP is not supported, ensuring
no silent fallback is attempted.
- Around line 49-55: The latitude/longitude parsing currently only checks
numeric format in MockGeoLocationAction (see parsing of latVal and longVal) but
misses range validation; after parsing latitude in the block that sets
"latitude" and before continuing, add a check that latitude is between -90 and
90 and, if out of range, call setErrorMessage with a clear message and return
Result.FAILED; do the same for longitude (range -180 to 180) in the block where
"longitude" is parsed, using the same pattern (setErrorMessage + return
Result.FAILED) and keep existing logging via logger.info for valid values.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c253bb2 and 6e1fb8d.

📒 Files selected for processing (1)
  • mock_geo_location/src/main/java/com/testsigma/addons/mobileweb/MockGeoLocationAction.java

Comment on lines +105 to +116
} else if (this.driver instanceof RemoteWebDriver) {
// Reflection hack for RemoteWebDriver to bypass HasDevTools/Augmenter
Method execute = RemoteWebDriver.class.getDeclaredMethod("execute", String.class, Map.class);
execute.setAccessible(true);
Map<String, Object> params = new HashMap<>();
params.put("cmd", "Emulation.setGeolocationOverride");
params.put("params", coordinates);
execute.invoke(this.driver, "executeCdpCommand", params);
logger.info("Fallback to RemoteWebDriver execution successful.");
} else {
throw e; // Rethrow if no fallback is possible
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reflection-based fallback is likely non-functional.

The RemoteWebDriver.execute() method is an internal method for W3C WebDriver protocol commands, not CDP commands. Passing "executeCdpCommand" as the command name won't work because it's not a recognized W3C command. The nested params structure also doesn't match the expected format.

If the driver doesn't implement HasCdp or isn't a ChromiumDriver, it likely doesn't support CDP at all. Consider removing this fallback or providing a clear error message indicating CDP is not supported.

Proposed fix to replace with clear error handling
         } else if (this.driver instanceof ChromiumDriver) {
           ((ChromiumDriver) this.driver).executeCdpCommand("Emulation.setGeolocationOverride", coordinates);
           logger.info("Fallback to ChromiumDriver (Chrome/Edge) execution successful.");
-        } else if (this.driver instanceof RemoteWebDriver) {
-          // Reflection hack for RemoteWebDriver to bypass HasDevTools/Augmenter
-          Method execute = RemoteWebDriver.class.getDeclaredMethod("execute", String.class, Map.class);
-          execute.setAccessible(true);
-          Map<String, Object> params = new HashMap<>();
-          params.put("cmd", "Emulation.setGeolocationOverride");
-          params.put("params", coordinates);
-          execute.invoke(this.driver, "executeCdpCommand", params);
-          logger.info("Fallback to RemoteWebDriver execution successful.");
         } else {
-          throw e; // Rethrow if no fallback is possible
+          throw new UnsupportedOperationException(
+              "Driver does not support CDP commands. Geolocation override requires Chrome/Chromium-based browser with DevTools support.");
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else if (this.driver instanceof RemoteWebDriver) {
// Reflection hack for RemoteWebDriver to bypass HasDevTools/Augmenter
Method execute = RemoteWebDriver.class.getDeclaredMethod("execute", String.class, Map.class);
execute.setAccessible(true);
Map<String, Object> params = new HashMap<>();
params.put("cmd", "Emulation.setGeolocationOverride");
params.put("params", coordinates);
execute.invoke(this.driver, "executeCdpCommand", params);
logger.info("Fallback to RemoteWebDriver execution successful.");
} else {
throw e; // Rethrow if no fallback is possible
}
} else if (this.driver instanceof ChromiumDriver) {
((ChromiumDriver) this.driver).executeCdpCommand("Emulation.setGeolocationOverride", coordinates);
logger.info("Fallback to ChromiumDriver (Chrome/Edge) execution successful.");
} else {
throw new UnsupportedOperationException(
"Driver does not support CDP commands. Geolocation override requires Chrome/Chromium-based browser with DevTools support.");
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mock_geo_location/src/main/java/com/testsigma/addons/mobileweb/MockGeoLocationAction.java`
around lines 105 - 116, The reflection-based RemoteWebDriver fallback in
MockGeoLocationAction (the block using
RemoteWebDriver.class.getDeclaredMethod("execute", ...) and invoking
"executeCdpCommand") is non-functional for CDP; remove this reflection hack and
replace it with clear error handling: detect lack of CDP support (check for
instances of HasCdp or ChromiumDriver earlier) and when neither is available
throw or log a descriptive UnsupportedOperationException/RuntimeException that
includes the driver class name and a message that CDP is not supported, ensuring
no silent fallback is attempted.

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.

1 participant