Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix/39660 Web Agent Page Enhancement #3830

Merged

Conversation

GokulBothe99
Copy link
Contributor

@GokulBothe99 GokulBothe99 commented Jul 15, 2024

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 checkbox for enabling browser private mode.
    • Introduced a new stack panel for user profile folder path.
    • Added a checkbox for enabling native events.
  • Enhancements

    • Improved layout and styling of UI elements for better user experience.
    • Updated UI to include WebBrowserType.Brave.
    • Enhanced browser handling logic, including support for Brave and Edge browsers.
  • Refactor

    • Renamed and reorganized methods to improve code readability.
    • Modified event handling for proxy settings.

Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

The updates primarily enhance UI configurations for web agents, browser handling for Selenium and Playwright drivers, and proxy settings. This includes visual and functional improvements in the WebAgentConfigEditPage, browser-specific adjustments in SeleniumDriver, and refined property management in PlaywrightDriver.

Changes

Files/Paths Change Summary
.../WebAgentConfigEditPage.xaml.cs Adjusted UI layout and styling, renamed labels for proxy settings, added checkboxes for browser private mode and native events, reorganized stack panels, and updated bindings and logic for browser-related settings.
.../Selenium/SeleniumDriver.cs Added Edge browser paths, modified enums, removed some properties, refactored methods for setting browser behavior, and updated logic for Brave and Edge browsers.
.../Playwright/PlaywrightDriver.cs Removed HeadlessBrowserMode and Proxy properties, introduced ByPassProxy, and modified element handling logic.

Sequence Diagram(s)

Browser Configuration Updates

sequenceDiagram
    participant User
    participant WebAgentConfigEditPage
    participant SeleniumDriver
    participant PlaywrightDriver

    User->>WebAgentConfigEditPage: Update Browser Settings
    WebAgentConfigEditPage->>SeleniumDriver: Adjust based on Browser Type
    SeleniumDriver-->>WebAgentConfigEditPage: Updated Settings
    WebAgentConfigEditPage->>PlaywrightDriver: Adjust based on Browser Type
    PlaywrightDriver-->>WebAgentConfigEditPage: Updated Settings
    WebAgentConfigEditPage-->>User: Display Updated Configuration
Loading

Poem

In the code, a new breeze flows,
Browsers dance where logic grows.
Proxy paths and settings shift,
UI elements get a lift.
Brave and Edge now take their place,
In this coding rabbit race. 🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@GokulBothe99 GokulBothe99 changed the base branch from master to Releases/Official-Release July 15, 2024 14:48
Copy link
Contributor

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

Caution

Inline review comments failed to post

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
Ginger/GingerCoreNET/ValueExpressionLib/ValueExpression.cs (1)

33-39: Remove unnecessary using directive.

The System.Net using directive in Ginger/GingerCoreNET/ValueExpressionLib/ValueExpression.cs is not used and should be removed to clean up the code.

  • Ginger/GingerCoreNET/ValueExpressionLib/ValueExpression.cs: using System.Net;
Analysis chain

Verify the necessity of new usings.

Ensure that the newly added usings for SikuliStandard.sikuli_REST and System.Net are necessary and used appropriately in the code.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the necessity and usage of new usings.

# Test: Search for the usage of `SikuliStandard.sikuli_REST`. Expect: At least one occurrence.
rg --type cs 'SikuliStandard.sikuli_REST'

# Test: Search for the usage of `System.Net`. Expect: At least one occurrence.
rg --type cs 'System.Net'

Length of output: 35067

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8edea8d and 7bf47ff.

Files selected for processing (13)
  • Ginger/Ginger/Agents/AgentDriverConfigPage.xaml.cs (1 hunks)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml (8 hunks)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (9 hunks)
  • Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml.cs (1 hunks)
  • Ginger/Ginger/UserControlsLib/UCElementDetails.xaml.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (6 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/GingerWebDriver.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (5 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (3 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (15 hunks)
  • Ginger/GingerCoreNET/RosLynLib/CodeProcessor.cs (7 hunks)
  • Ginger/GingerCoreNET/ValueExpressionLib/ValueExpression.cs (3 hunks)
  • Ginger/GingerCoreNETUnitTest/RosLynTestLib/GlobalsTest.cs (4 hunks)
Files skipped from review due to trivial changes (2)
  • Ginger/Ginger/Agents/AgentDriverConfigPage.xaml.cs
  • Ginger/Ginger/UserControlsLib/UCElementDetails.xaml.cs
Additional context used
Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (2)
Learnt from: prashelke
PR: Ginger-Automation/Ginger#3429
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs:1581-1616
Timestamp: 2024-01-05T14:23:27.219Z
Learning: The user has implemented the use of `using` statements for `Bitmap` objects and added a `finally` block to clear the `bitmapsToMerge` list. They have also handled exceptions that may occur during bitmap operations.
Learnt from: prashelke
PR: Ginger-Automation/Ginger#3429
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs:1581-1616
Timestamp: 2024-01-05T14:23:27.219Z
Learning: The user has implemented the use of `using` statements for `Bitmap` objects and added a `finally` block to clear the `bitmapsToMerge` list. They have also handled exceptions that may occur during bitmap operations.
GitHub Check: Codacy Static Code Analysis
Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs

[notice] 385-385: Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs#L385
Remove the unnecessary Boolean literal(s).

Additional comments not posted (57)
Ginger/GingerCoreNETUnitTest/RosLynTestLib/GlobalsTest.cs (4)

23-28: LGTM!

The added using directives are appropriate for the new functionality.


308-308: LGTM!

The test method TestBogusData_RandomizerNumber_IsNotnullAndEmpty is well-structured and appropriate.


317-317: LGTM!

The test method TestBogusData_RandomizerDigits_IsNotnullAndEmpty is well-structured and appropriate.


326-326: LGTM!

The test method TestBogusData_RandomizerDecimal_IsNotnullAndEmpty is well-structured and appropriate.

Ginger/GingerCoreNET/RosLynLib/CodeProcessor.cs (5)

22-32: LGTM!

The added using directives are appropriate for the new functionality.


71-81: LGTM!

The updates to the GetResult method improve its robustness and accuracy.


115-123: LGTM!

The updates to the GetEvaluteResult method improve its ability to handle various data types.


273-303: LGTM!

The updates to the GetBogusDataGenerateresult method improve its robustness and accuracy.


Line range hint 318-386: LGTM!

The updates to the GetBogusExpressionEvaluteResult method improve its ability to handle various data generation expressions.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/GingerWebDriver.cs (4)

46-48: LGTM!

The new property Proxy enhances the configurability of the web driver.


50-53: LGTM!

The new property ByPassProxy enhances the configurability of the web driver.


54-54: LGTM!

The new property BrowserType enhances the configurability of the web driver.


61-64: LGTM!

The new property HeadlessBrowserMode enhances the configurability of the web driver.

Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (6)

52-53: LGTM!

The updates to the constructor improve the handling of browser-specific settings and proxy configurations.


Line range hint 86-239: LGTM!

The updates to the bindElement method improve the configurability of the web agent.


303-305: LGTM!

The updates to the BrowserTypeParam_PropertyChanged method improve the handling of browser-specific settings.


311-322: LGTM!

The new method allBrowserNotBravePnl enhances the configurability of the web agent.


383-392: LGTM!

The updates to the proxyPnlVisbility method improve the handling of proxy configurations.

Tools
GitHub Check: Codacy Static Code Analysis

[notice] 385-385: Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs#L385
Remove the unnecessary Boolean literal(s).


395-398: LGTM!

The updates to the xAutoDetectProxyCB_Click method improve the handling of proxy configurations.

Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml (4)

11-11: LGTM!

The grid definition and initial setup are correct.


38-38: LGTM!

The checkbox for auto-detecting proxy settings is correctly defined and styled.


45-49: LGTM!

The new fields for proxy settings are correctly defined and styled.


Line range hint 78-152: LGTM!

The new checkboxes for browser private mode and enable native events are correctly defined and styled.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (7)

62-64: LGTM!

The method signature change to accept a list of learned elements is appropriate and improves flexibility.


67-83: LGTM!

The method signature change to accept a list of learned elements is appropriate and improves flexibility.


Line range hint 86-139: LGTM!

The method signature change to accept a predicate for filtering elements and a list of learned elements is appropriate and improves flexibility and control.


143-162: LGTM!

The change to make the method static and rename it is appropriate for clarity and consistency.


164-177: LGTM!

The change to use the static method CheckStaticHtmlNodeExclusion is appropriate for consistency.


Line range hint 765-790: LGTM!

The method signature change to accept a list of learned elements is appropriate and improves flexibility.


795-827: LGTM!

The method signature change to accept a list of learned elements is appropriate and improves flexibility.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (3)

68-74: Verify the correctness of the new proxy settings logic.

The logic for handling proxy settings and bypass proxy settings appears correct. Ensure that the Proxy and ByPassProxy properties are correctly set and used across the codebase.


595-614: Verify the correctness of the null handling and learned elements logic.

The changes correctly handle null foundElementsList and update the logic for learned elements. Ensure that the foundElementsList is correctly initialized and updated across the codebase.


617-617: Verify the correctness of the new PlaywrightBrowserElementProvider class.

The new class PlaywrightBrowserElementProvider is correctly integrated. Ensure that the methods for getting elements and handling frames and shadow DOM are correctly implemented and used across the codebase.

Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml.cs (1)

332-332: Good use of the null-conditional operator.

This change improves error handling by preventing a potential null reference exception.

Ginger/GingerCoreNET/ValueExpressionLib/ValueExpression.cs (2)

113-114: Verify the correctness and usage of new regex patterns.

Ensure that the newly added regex patterns MockDataExpPattern and CsExppattern are correctly defined and used appropriately in the code.


1735-1787: Verify the correctness of method updates.

Ensure that the updates to the ContainsFormula method correctly include checks for the new regex patterns.

Verification successful

The updates to the ContainsFormula method are correct.

The method correctly includes checks for the new regex patterns, which are properly defined and compiled in the codebase.

  • Regex patterns are appropriately defined and used in the ContainsFormula method.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of method updates.

# Test: Search for the usage of `ContainsFormula`. Expect: At least one occurrence.
rg --type cs 'ContainsFormula'

Length of output: 324


Script:

#!/bin/bash
# Description: Verify the regex patterns used in the ContainsFormula method.

# Search for the definitions of the regex patterns used in the ContainsFormula method.
rg --type cs 'rxGlobalParamPattern|rxEnvParamPattern|rxEnvUrlPattern|rxe|VBSRegex|rNestedfunc|rxDSPattern|rxFDPattern|rxExecutionJsonDataPattern|CsExppattern|MockDataExpPattern'

Length of output: 7940

Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs (6)

1642-1642: LGTM!

Returning null on error is a good practice for consistent error handling.


3435-3447: LGTM!

Handling null package values and response errors improves the robustness of the function.


3406-3406: LGTM!

Including a null response check enhances error handling.


3390-3400: LGTM!

Handling null package values prevents the function from sending invalid requests.


3488-3505: LGTM!

Including exception handling improves the robustness of the function.


1130-1130: LGTM!

The new logic for handling ActMobileDevice.eMobileDeviceAction.GetDeviceNetwork is correct and improves the functionality.

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

79-79: LGTM!

The new using statements and static import are appropriate.


104-105: LGTM!

The constants for Edge browser paths and variable initializations are appropriate.


125-151: LGTM!

The new enums for browser configurations improve code readability and maintainability.


143-143: LGTM!

The new property for proxy auto-config URL is useful and well-annotated.


191-191: LGTM!

The properties for auto-detecting proxy settings, extension path, and clearing IE cache enhance configurability.


230-238: LGTM!

The properties for browser private mode, minimized mode, log level, and IE mode in Edge provide useful configuration options.


297-297: LGTM!

The properties for page load timeout and page load strategy are useful for configuring page load behavior.


337-337: LGTM!

The property for unhandled prompt behavior with a user-configured default is useful for handling browser prompts.


694-694: LGTM!

The logic for checking the Brave browser path and configuring the Chrome driver ensures proper browser setup.


709-709: LGTM!

The exception handling for an invalid Brave browser path and driver configuration is appropriate.


718-742: LGTM!

The logic for checking the Edge browser path and configuring IE options ensures proper browser setup.


795-798: LGTM!

The logic for setting the browser version and handling headless mode for Edge is appropriate.


1280-1281: LGTM!

The null check for the proxy configuration ensures safe handling.


6619-6623: LGTM!

The logic for handling XPath lists and search context is appropriate.


10751-10754: LGTM!

The method for setting the browser log level ensures proper logging configuration.

Comments failed to post (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Mobile/Appium/GenericAppiumDriver.cs

747-752: Correctness: Validate coordinates before performing the action.

Ensure that the coordinates are valid integers before performing the touch action to avoid runtime errors.

-  tc.Press(Convert.ToInt32(act.GetInputParamCalculatedValue(ActUIElement.Fields.XCoordinate)), Convert.ToInt32(act.GetInputParamCalculatedValue(ActUIElement.Fields.YCoordinate))).Perform();
+  int x, y;
+  if (int.TryParse(act.GetInputParamCalculatedValue(ActUIElement.Fields.XCoordinate), out x) && int.TryParse(act.GetInputParamCalculatedValue(ActUIElement.Fields.YCoordinate), out y)) {
+    tc.Press(x, y).Perform();
+  } else {
+    act.Error = "Invalid coordinates.";
+  }
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.

                    case ActUIElement.eElementAction.ClickXY:
                        ITouchAction tc;
                        tc = new TouchAction(Driver);
                        int x, y;
                        if (int.TryParse(act.GetInputParamCalculatedValue(ActUIElement.Fields.XCoordinate), out x) && int.TryParse(act.GetInputParamCalculatedValue(ActUIElement.Fields.YCoordinate), out y)) {
                            tc.Press(x, y).Perform();
                        } else {
                            act.Error = "Invalid coordinates.";
                        }
                        break;

Copy link
Contributor

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7bf47ff and 6bb46ae.

Files selected for processing (2)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs (9 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (13 hunks)
Files skipped from review as they are similar to previous changes (2)
  • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs

@Maheshkale447 Maheshkale447 merged commit 71407f7 into Releases/Official-Release Jul 15, 2024
6 of 9 checks passed
@Maheshkale447 Maheshkale447 deleted the BugFix/39660_WebAgentConfigEnhancement branch July 15, 2024 19:04
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.

None yet

2 participants