Skip to content

Edge Browser support version 127 only for dev tool fix#4212

Merged
Maheshkale447 merged 2 commits into
Releases/Official-Releasefrom
BugFix/EdgeNetworkLogFix
May 14, 2025
Merged

Edge Browser support version 127 only for dev tool fix#4212
Maheshkale447 merged 2 commits into
Releases/Official-Releasefrom
BugFix/EdgeNetworkLogFix

Conversation

@prashelke

@prashelke prashelke commented May 13, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with Chromium-based browsers by explicitly specifying the DevTools protocol version when initializing DevTools sessions.

@coderabbitai

coderabbitai Bot commented May 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The change updates the SetUPDevTools method in the SeleniumDriver class to explicitly pass the version number 127 when obtaining a DevTools session. No other logic or method signatures are altered.

Changes

File(s) Change Summary
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs Added constant DevToolsProtocolVersion = 127 and modified SetUPDevTools to call GetDevToolsSession(127) instead of parameterless GetDevToolsSession().

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

A tweak to the code, so neat and precise,
DevTools now knows its version device.
Selenium hops with a version in tow,
127, the number to know!
The browser and rabbit, both ready to run,
Debugging adventures have only begun! 🐇💻

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 683f02b and 6bd7b41.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (2 hunks)
🔇 Additional comments (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (2)

103-103: Good addition of the named constant for DevTools protocol version.

This is a positive change that moves away from using the magic number directly in the method call. Having a named constant makes the code more maintainable and ensures that when the protocol version needs to be updated in the future, it can be done in a single location.


10897-10897:

Details

✅ Verification successful

Using the constant improves code maintainability.

Good improvement to use the newly defined constant instead of hardcoding the protocol version directly in the method call. This makes the code easier to maintain when Edge updates its DevTools protocol version.

For even better future-proofing, consider implementing a dynamic version detection mechanism. You could check if a more robust solution is possible by searching:


🌐 Web query:

How to dynamically determine DevTools protocol version in Selenium C#

💡 Result:

Dynamically Determining DevTools Protocol Version in Selenium C#

When working with Selenium C# and Chrome DevTools Protocol (CDP), it's important to align your DevTools session and code to the correct protocol version that matches your Chrome browser. Selenium 4's CDP integration is heavily version-specific, meaning that the API wrappers and commands are tied to specific Chrome/DevTools protocol versions[2][5][6][7].

Why Is This Needed?

  • The DevTools (CDP) APIs in Selenium C# are organized into versioned namespaces such as OpenQA.Selenium.DevTools.V91 or OpenQA.Selenium.DevTools.V130, depending on Chrome's protocol version[5][6].
  • Using the wrong version typically results in runtime errors or missing definitions for certain domains/methods[4][8].

Key Concepts

  • DevToolsSession: Main entry point to interact with CDP in Selenium.
  • Version-Specific Domains: You must reference and use domain classes (e.g., Network, Page, etc.) from the namespace matching your browser's CDP protocol version[6][5].
  • Protocol Version Discovery: Selenium does not always automatically detect the right protocol version, especially in newer C# bindings[8].

Practical Steps

1. Detect the Chrome/DevTools Protocol Version

  • The DevTools protocol version often closely tracks Chrome browser versions, but there isn't a one-to-one mapping. The official CDP version table is most accurate for mapping.
  • In C#, Selenium does not always provide an automatic way to determine and load the correct CDP version for you. When the protocol version cannot be automatically detected, a warning or error such as:

"A WebSocket address for DevTools protocol has been detected, but the protocol version cannot be automatically detected. You must specify a protocol version."[8]

  • Generally, you need to:
    1. Programmatically detect the browser version (e.g., via driver.Capabilities).
    2. Map it to the appropriate CDP version.
    3. Use the corresponding versioned namespace in your code.

2. Example: Using Versioned DevTools Domains in C#

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.DevTools;
using OpenQA.Selenium.DevTools.V130.Network; // Use the version matching your browser/protocol

var driver = new ChromeDriver();
DevToolsSession devToolsSession = ((ChromeDriver)driver).GetDevToolsSession();
var network = devToolsSession.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V130.DevToolsSessionDomains>().Network;

network.Enable(new EnableCommandSettings());
// Now you can subscribe to events, send commands, etc.

You must replace V130 with the actual namespace matching your Chrome's CDP version[6][5].

3. Automating the Version Mapping

There is no built-in Selenium API to dynamically resolve and generate the correct using directive at runtime, since these are compile-time dependencies. However, you can:

  • Detect the browser version at runtime.
  • Maintain a mapping (dictionary) in your code between Chrome versions and the corresponding DevTools protocol version.
  • Use reflection (advanced) or factory pattern to instantiate the correct domain classes at runtime, if you really want to automate it. However, the most robust approach is to ensure your test environment uses a known version of Chrome and the matching Selenium DevTools package[6][5][10].

4. Example of Mapping Browser to CDP Version

  1. Retrieve the browser version:

    var chromeVersion = ((ChromeDriver)driver).Capabilities.GetCapability("browserVersion").ToString();
  2. Use a lookup table (manually maintained or generated from the CDP protocol mapping page) to find the corresponding DevTools version.

  3. Reference the correct namespace in your code. You cannot dynamically reference namespaces at runtime in C# without advanced reflection or code generation.

5. Handling Protocol Version Errors

If you do not match the correct version, expect errors or warnings about unsupported protocol versions and missing features[8][10].

Summary Table

Task Method/Approach
Determine Chrome Version Use driver capabilities
Map to CDP Version Use a lookup table (from official CDP docs)
Reference CDP Namespace in Code Use correct using OpenQA.Selenium.DevTools.VXXX;
Dynamic Loading (advanced) Reflection/factory pattern, but rarely needed in practice
Error if Version Mismatch "Cannot be automatically detected. You must specify version."

Conclusion

There is currently no fully dynamic way to determine and load the correct DevTools protocol version in Selenium C#, because the necessary type definitions are determined at compile time[5][6][8]. The standard practice is:

  • Manually match your Selenium DevTools package version (and corresponding namespace) to your browser's CDP version.
  • Keep browser and driver versions synchronized in your CI/CD or test environment.
  • Use runtime detection and factory patterns if you need to support multiple versions in one codebase, but this requires more sophisticated C# techniques.

For most projects, the best approach is to standardize on a tested Chrome + CDP + Selenium version combination and reference the correct DevTools namespace in your code[5][6].

Citations:


Using Constant Is Ideal; Dynamic CDP Version Loading Isn’t Supported in C#

Great job replacing the hard-coded protocol version with the DevToolsProtocolVersion constant—this will save maintenance headaches whenever Edge’s CDP version is bumped.

Note: Selenium’s C# CDP bindings use compile-time namespaces (e.g. OpenQA.Selenium.DevTools.V130), and there is no built-in way to autodetect and reference the correct namespace at runtime. If you do need to support multiple CDP versions in one codebase, consider:

  • Getting the browser version at runtime via ((ChromeDriver)driver).Capabilities.GetCapability("browserVersion").
  • Maintaining a lookup table from browser versions to CDP namespace versions.
  • Using a simple factory or reflection to instantiate the appropriate DevToolsSessionDomains.
  • Locking your CI/CD Chrome + CDP + Selenium versions to a known combination to avoid version mismatches.

File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs
Line: 10897

devToolsSession = devTools.GetDevToolsSession(DevToolsProtocolVersion);
✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@prashelke
prashelke requested a review from Maheshkale447 May 13, 2025 14:58

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7336b0e and 683f02b.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1 hunks)

Comment thread Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs Outdated
@Maheshkale447
Maheshkale447 merged commit a5b9d53 into Releases/Official-Release May 14, 2025
@Maheshkale447
Maheshkale447 deleted the BugFix/EdgeNetworkLogFix branch May 14, 2025 07:25
@coderabbitai coderabbitai Bot mentioned this pull request May 30, 2025
15 tasks
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