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

BugFix - 39649 - Not Able To Learn Shadow DOM Elements #3826

Conversation

IamRanjeetSingh
Copy link
Contributor

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

    • Enhanced HTML element learning process by adding a new parameter for selective node learning.
    • Improved Playwright driver with shadow DOM handling and exception management.
    • Added timeout parameter for capturing screenshots in Playwright Browser Element.
  • Refactor

    • Namespace updates and minor formatting changes for better code organization.
  • Bug Fixes

    • Fixed issue with shadow DOM element recognition in Playwright.
  • Chores

    • Removed unnecessary import statements to clean up the codebase.

Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

The updates enhance the POMLearner functionality to better handle learning HTML elements, including shadow DOM elements, and integrate Playwright driver improvements for handling and locating elements within shadow DOMs. Additionally, the Playwright and Selenium drivers' dependencies and structure were refined, and a timeout parameter was added to Playwright's screenshot method.

Changes

File Path Change Summary
.../CoreDrivers/Web/POM/POMLearner.cs Added shouldLearnNode parameter to LearnHtmlNodeChildElements, improved exception and screenshot handling in CreateHTMLElementInfoAsync, and adjusted related methods.
.../CoreDrivers/Web/Playwright/PlaywrightDriver.cs Introduced _shadowDOMDepth to manage shadow DOM elements, updated GetElementAsync for shadow DOM handling, added exception handling, and adjusted _shadowDOMDepth logic.
.../CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs Added timeout parameter to ScreenshotAsync method for specifying screenshot capture timeout.
.../CoreDrivers/Web/Selenium/SeleniumDriver.cs Removed the import statement for Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web.Selenium.
.../CoreDrivers/Web/ShadowDOM.cs Changed the namespace to Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web and made minor formatting adjustments.

Poem

In the land of code, a tale unfolds,
Of shadow DOMs and elements bold.
With Playwright's grace, and POM's embrace,
Screenshots taken with a timely pace.
Refined and neat, our browsers greet,
A framework whole, no challenge too fleet.
🌐🐇✨


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.

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 e2d7697 and b97d77a.

Files selected for processing (2)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (8 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (4 hunks)
Additional context used
Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2)
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#3811
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:386-410
Timestamp: 2024-07-08T14:02:08.377Z
Learning: When suggesting to avoid throwing `System.Exception` directly, if the user defers the change, acknowledge their decision and note that the change might be considered in future revisions.
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#3811
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:392-407
Timestamp: 2024-07-08T13:53:26.335Z
Learning: When suggesting to avoid throwing `System.Exception` directly, if the user defers the change, acknowledge their decision and note that the change might be considered in future revisions.
Additional comments not posted (9)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (6)

81-127: LGTM! Ensure correct usage of the new parameter.

The addition of the Predicate<HtmlNode> shouldLearnNode parameter enhances the flexibility of the method. Ensure that the predicate is correctly used throughout the codebase.


Line range hint 132-149:
LGTM! The logic improvements are sound.

The updates to the IsNodeLearnable method improve the accuracy of determining if a node is learnable.


Line range hint 153-159:
LGTM! The logic remains sound.

The ShouldLearnFormChildNode method correctly determines if a form child node should be learned based on its tag name.


198-198: LGTM! Ensure robust exception handling.

The updates to the CreateHTMLElementInfoAsync method improve the handling of screenshots and exceptions. Ensure that the exception handling is robust and covers all edge cases.


Line range hint 737-753:
LGTM! Ensure robust exception handling.

The updates to the GetElementScreenshotAsync method improve the handling of screenshots and exceptions. Ensure that the exception handling is robust and covers all edge cases.


762-762: LGTM! The logic improvements are sound.

The updates to the LearnShadowDOMElementsAsync method improve the handling of shadow DOM elements.

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

633-645: LGTM! Ensure robust exception handling.

The updates to the GetElementAsync method improve the handling of shadow DOM elements and enhance exception handling. Ensure that the exception handling is robust and covers all edge cases.


668-668: LGTM! The logic improvements are sound.

The updates to the OnShadowDOMEnterAsync method accurately track the depth of the shadow DOM.


674-674: LGTM! The logic improvements are sound.

The updates to the OnShadowDOMExitAsync method accurately track the depth of the shadow DOM.

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 b97d77a and cae699a.

Files selected for processing (5)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (8 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (3 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ShadowDOM.cs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
Additional context used
Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (4)
Learnt from: manas-droid
PR: Ginger-Automation/Ginger#3436
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs:6702-6749
Timestamp: 2024-01-10T08:58:17.226Z
Learning: The user has indicated that the commented `CheckifPageLoaded` method is needed for later use, suggesting a requirement to retain the code within the source files for reference or potential re-implementation.
Learnt from: manas-droid
PR: Ginger-Automation/Ginger#3436
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs:6702-6749
Timestamp: 2024-01-10T08:58:17.226Z
Learning: The user has indicated that the commented `CheckifPageLoaded` method is needed for later use, suggesting a requirement to retain the code within the source files for reference or potential re-implementation.
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.
Additional comments not posted (6)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ShadowDOM.cs (1)

25-25: Namespace change approved.

The namespace change from Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web.Selenium to Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web is correct and simplifies the hierarchy.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (1)

822-848: Changes to ScreenshotAsync method approved.

The addition of a timeout parameter to the ScreenshotAsync method is a useful enhancement and is correctly implemented.

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

69-69: Changes to LearnHtmlNodeChildElements method approved.

The addition of the shouldLearnNode parameter allows for more flexible learning of HTML nodes and is correctly implemented.


202-202: Changes to CreateHTMLElementInfoAsync method approved.

The enhancements for better screenshot handling and exception management improve the robustness of the method and are correctly implemented.


Line range hint 741-757: Changes to GetElementScreenshotAsync method approved.

The enhanced exception handling improves the robustness of the method and is correctly implemented.

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

Line range hint 1-6:
Verify the correctness of the new import statement.

The import statement for Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web.Selenium was removed and replaced with Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web. Ensure that the new import statement is correct and all necessary classes and methods are available in the new namespace.

Verification successful

The new import statement is correct.

The namespace Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web is correctly utilized across the codebase, indicating that the changes are appropriate and do not introduce any issues.

  • Files where the new namespace is used correctly:
    • Ginger/GingerTest/Variable Dependancies/VariableDependancyTest.cs
    • Ginger/GingerTest/AgentsLib/AgentsTest.cs
    • Ginger/GingerRuntime/DotnetCoreHelper.cs
    • Ginger/GingerCoreTest/UITests/WebDriverUnitTestCase.cs
    • Ginger/GingerCoreTest/UITests/VisualCompareTest.cs
    • Ginger/GingerCoreNETUnitTest/GingerRunnerTests/GingerRunnerTest.cs
    • Ginger/GingerCoreNETUnitTest/LinuxTransformationTests/RunSetActionGenerateTestNGReportTests.cs
    • Ginger/GingerCoreNETUnitTest/GingerRunnerTests/CleanUpActivityTests.cs
    • Ginger/GingerCoreNETUnitTest/Drivers/CoreDrivers/Web/POM/POMLocatorParserTests.cs
    • Ginger/GingerCoreNETUnitTest/Drivers/CoreDrivers/Web/ActionHandlers/ActScreenShotHandlerTests.cs
    • Ginger/GingerCoreTest/UITests/ActUIElementTest.cs
    • Ginger/GingerCoreTest/Misc/NonDriverActionTest.cs
    • Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ShadowDOM.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/GingerWebDriver.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserWindow.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserTab.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserShadowRoot.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserDialog.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowser.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserWindow.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserTab.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserShadowRoot.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserElement.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLocatorParser.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowser.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActScreenShotHandler.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Exceptions/LocatorNotSupportedException.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActGotoURLHandler.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActBrowserElementHandler.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMElementLocator.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Exceptions/InvalidActionConfigurationException.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Exceptions/EntityNotFoundException.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs
    • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserDialog.cs
    • Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs
    • Ginger/Ginger/Drivers/DriversConfigsEditPages/WebAgentConfigEditPage.xaml.cs
    • Ginger/Ginger/DotNetFrameworkHelper.cs
    • Ginger/Ginger/Agents/AgentEditPage.xaml.cs
    • Ginger/Ginger/Agents/AddAgentWizardLib/AddAgentDetailsPage.xaml.cs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new import statement.

# Test: Search for the usage of the new namespace. Expect: The new namespace should be used correctly.
rg --type cs 'Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web' -A 5

Length of output: 33733

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 cae699a and 6cebaec.

Files selected for processing (3)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (8 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (1 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
Additional comments not posted (5)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/POM/POMLearner.cs (5)

87-87: LGTM!

The addition of the shouldLearnNode predicate to filter nodes is a good enhancement.


99-145: LGTM!

The addition of the shouldLearnNode predicate to filter nodes is a good enhancement.


Line range hint 759-775:
LGTM!

The addition of exception handling and returning null in case of errors is a good enhancement.


Line range hint 775-797:
LGTM!

The addition of the check for ShadowRootAsync is a good enhancement.


171-181: LGTM!

The addition of error handling is a good enhancement.

@Maheshkale447 Maheshkale447 merged commit ca8400b into Releases/Official-Release Jul 15, 2024
6 of 9 checks passed
@Maheshkale447 Maheshkale447 deleted the BugFix/39649-NotAbleToLearnShadowRootElements branch July 15, 2024 14:52
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