Skip to content

Remote web Driver support added for all type of browser#4089

Merged
Maheshkale447 merged 2 commits into
masterfrom
Feature/RemoteDriverEnhancement
Feb 10, 2025
Merged

Remote web Driver support added for all type of browser#4089
Maheshkale447 merged 2 commits into
masterfrom
Feature/RemoteDriverEnhancement

Conversation

@prashelke

@prashelke prashelke commented Feb 7, 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

  • New Features
    • Added a new configuration option within Advanced Settings to allow specifying a Remote Web Driver URL.
    • Enhanced the driver connection process to utilize the provided URL for remote browser automation while retaining local driver support when no URL is given.

@coderabbitai

coderabbitai Bot commented Feb 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request introduces a new configuration option for specifying a Remote Web Driver URL. A new UI panel is added to the WebAgentConfigEditPage.xaml, which includes a label and an input control. The code-behind in WebAgentConfigEditPage.xaml.cs initializes a new configuration parameter and binds it to the UI. Additionally, the SeleniumDriver class now defines a RemoteWebDriverUrl property and adjusts its driver initialization logic to create a remote driver instance when a valid URL is provided.

Changes

Files Change Summary
Ginger/.../WebAgentConfigEditPage.xaml
Ginger/.../WebAgentConfigEditPage.xaml.cs
Added a new StackPanel with a Label and UCValueExpression control for the Remote Web Driver URL in the "Advance settings" section. The code-behind initializes and binds a new configuration parameter for this URL.
Ginger/.../SeleniumDriver.cs Introduced a new public property RemoteWebDriverUrl with configuration attributes. Updated driver initialization logic: if a URL is provided, a RemoteWebDriver instance is created with error handling; otherwise, the local driver initialization is retained.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as WebAgentConfigEditPage
    participant C as ConfigHandler
    participant S as SeleniumDriver
    participant R as RemoteWebDriver
    participant L as LocalDriver

    U->>A: Enter Remote Web Driver URL
    A->>C: Update configuration parameter
    C->>S: Pass RemoteWebDriverUrl value
    S->>S: Check if URL is provided
    alt Remote URL provided
        S->>R: Initialize RemoteWebDriver with URL
    else
        S->>L: Initialize LocalDriver
    end
    S-->>C: Return driver instance
Loading

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

I'm a nimble rabbit, hopping with delight,
Through code and XAML, I scurry in light.
A new Remote URL panel makes the tests run free,
With Selenium driving remotely, just wait and see!
In every line of code, my happy heart does thump,
Celebrating fresh changes with a joyful hop and jump!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

@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: 3

🔭 Outside diff range comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1)

80-81: Consider breaking down large driver class

The SeleniumDriver class is over 11,000 lines and handles multiple responsibilities including browser automation, element location, recording, visual testing etc. Consider breaking it down into smaller focused classes following Single Responsibility Principle.

Some suggestions:

  • Extract element location logic into separate ElementLocator class
  • Move recording functionality into separate Recorder class
  • Create dedicated classes for visual testing and browser management
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 933b37f and 958843f.

📒 Files selected for processing (3)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml (1 hunks)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (4 hunks)
🔇 Additional comments (3)
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml (1)

212-215: LGTM!

The new remote web driver URL configuration panel follows the established pattern and maintains consistency with other configuration panels in terms of styling and layout.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (2)

397-401: New property added for Remote WebDriver support

The new property RemoteWebDriverUrl is added with appropriate user configuration attributes to allow specifying a remote WebDriver URL.


1119-1127: Remote WebDriver support added for Chrome browser

The code now checks for RemoteWebDriverUrl and creates either a RemoteWebDriver or local ChromeDriver based on the URL configuration. The implementation follows good practices with proper error handling.

Comment on lines +221 to +224
//Remote Web Driver Url
DriverConfigParam RemoteWebDriverUrl = mAgent.GetOrCreateParam(nameof(SeleniumDriver.RemoteWebDriverUrl));
xRemoteWebDriverUrlVE.Init(null, RemoteWebDriverUrl, nameof(DriverConfigParam.Value));
BindingHandler.ObjFieldBinding(xRemoteWebDriverUrlVE, TextBox.ToolTipProperty, RemoteWebDriverUrl, nameof(DriverConfigParam.Description));

@coderabbitai coderabbitai Bot Feb 7, 2025

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.

🧹 Nitpick (assertive)

Follow C# naming conventions for local variables.

The local variable RemoteWebDriverUrl should be in camelCase to follow C# naming conventions.

Apply this diff to fix the naming:

-            DriverConfigParam RemoteWebDriverUrl = mAgent.GetOrCreateParam(nameof(SeleniumDriver.RemoteWebDriverUrl));
-            xRemoteWebDriverUrlVE.Init(null, RemoteWebDriverUrl, nameof(DriverConfigParam.Value));
-            BindingHandler.ObjFieldBinding(xRemoteWebDriverUrlVE, TextBox.ToolTipProperty, RemoteWebDriverUrl, nameof(DriverConfigParam.Description));
+            DriverConfigParam remoteWebDriverUrl = mAgent.GetOrCreateParam(nameof(SeleniumDriver.RemoteWebDriverUrl));
+            xRemoteWebDriverUrlVE.Init(null, remoteWebDriverUrl, nameof(DriverConfigParam.Value));
+            BindingHandler.ObjFieldBinding(xRemoteWebDriverUrlVE, TextBox.ToolTipProperty, remoteWebDriverUrl, nameof(DriverConfigParam.Description));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not needed

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.

@prashelke Understood, I'll move on from the naming suggestion.

Comment on lines +795 to +802
if (!string.IsNullOrEmpty(RemoteWebDriverUrl))
{
Driver = new RemoteWebDriver(new Uri(RemoteWebDriverUrl), ieOptions);
}
else
{
Driver = new InternetExplorerDriver((InternetExplorerDriverService)driverService, ieOptions, TimeSpan.FromSeconds(Convert.ToInt32(HttpServerTimeOut)));
}

@coderabbitai coderabbitai Bot Feb 7, 2025

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.

🧹 Nitpick (assertive)

Remote WebDriver support added for Edge browser with code duplication

The RemoteWebDriver initialization logic is duplicated for both IE mode and regular Edge mode. Consider refactoring to extract the common RemoteWebDriver initialization code into a separate method.

// Create a helper method
+ private IWebDriver CreateRemoteOrLocalDriver(Uri remoteUrl, DriverOptions options, DriverService service, int timeoutSeconds) {
+     return !string.IsNullOrEmpty(RemoteWebDriverUrl) 
+            ? new RemoteWebDriver(remoteUrl, options)
+            : new EdgeDriver((EdgeDriverService)service, options, TimeSpan.FromSeconds(timeoutSeconds));
+ }

Also applies to: 836-843

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no need of refactoring

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.

@prashelke Understood, I'll respect your decision to keep the current implementation as-is. The code works correctly in its current form.

(_/)/
(•-•)

🌟

Comment on lines +397 to +401

[UserConfigured]
[UserConfiguredDescription("Remote Web Driver Url")]
public string RemoteWebDriverUrl { get; set; }

@coderabbitai coderabbitai Bot Feb 7, 2025

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.

🧹 Nitpick (assertive)

Overall assessment of Remote WebDriver implementation

The changes successfully add Remote WebDriver support across Chrome, Edge and IE browsers. While the core functionality is implemented correctly, there are opportunities for improvement:

  1. Extract duplicated RemoteWebDriver initialization logic into helper methods
  2. Consider breaking down the large SeleniumDriver class into smaller focused classes
  3. Add XML documentation comments for the new RemoteWebDriverUrl property

The implementation is functional and can be merged, with the suggested improvements handled as follow-up refactoring tasks.

Also applies to: 795-802, 836-843, 1119-1127

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will handle it later

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.

@prashelke Understood, I'll add this to our knowledge base. Would you like me to create an issue to track these refactoring improvements for later?


✏️ Learnings added
Learnt from: prashelke
PR: Ginger-Automation/Ginger#4089
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs:397-401
Timestamp: 2025-02-07T12:11:25.466Z
Learning: The developer prefers to handle code refactoring and documentation improvements in separate PRs rather than as part of the initial implementation PR.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@Maheshkale447
Maheshkale447 merged commit b88062d into master Feb 10, 2025
@Maheshkale447
Maheshkale447 deleted the Feature/RemoteDriverEnhancement branch February 10, 2025 04:08
@coderabbitai coderabbitai Bot mentioned this pull request Mar 11, 2026
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