Skip to content

Playwright UI Element Action pending operation#4107

Merged
Maheshkale447 merged 8 commits into
Releases/Official-Releasefrom
BugFix/GitLibDowngrade
Feb 19, 2025
Merged

Playwright UI Element Action pending operation#4107
Maheshkale447 merged 8 commits into
Releases/Official-Releasefrom
BugFix/GitLibDowngrade

Conversation

@GokulBothe99

@GokulBothe99 GokulBothe99 commented Feb 17, 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
    • Enhanced drag and drop interactions, supporting both coordinate-based and target element operations via JavaScript and web drivers.
    • Added interactive drawing capabilities on UI elements.
    • Enabled simultaneous value assignment across multiple elements.
    • Improved JavaScript execution by allowing additional parameters for more flexible operations.

@GokulBothe99
GokulBothe99 changed the base branch from master to Releases/Official-Release February 17, 2025 06:27
@coderabbitai

coderabbitai Bot commented Feb 17, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request introduces new asynchronous operations to enhance UI element interactions. The changes add support for drag-and-drop (by coordinates or via target elements), drawing actions, and multi-element value settings in the UI element handler. The updates extend the IBrowserElement interface and its implementations (Playwright and Selenium drivers) with extra methods, and adjust the method signature for JavaScript execution. Additionally, an enumeration description update and new supported operations in the Playwright driver further integrate these functionalities into the overall UI automation framework.

Changes

File(s) Change Summary
Ginger/.../ActionHandlers/ActUIElementHandler.cs Added async methods: DragDropAsync, DrawObjectAsync, and MultiSetValueAsync with corresponding switch-case handling and error management.
Ginger/.../IBrowserElement.cs Introduced async methods: DrawObjectAsync, DragDropAsync, DragDropJSAsync, DragDropXYCordinateAsync; updated ExecuteJavascriptAsync signature with an optional parameter.
Ginger/.../Playwright/PlaywrightBrowserElement.cs Added methods: DragDropJSAsync, DragDropAsync, DragDropXYCordinateAsync, and DrawObjectAsync; updated multiple overloads of ExecuteJavascriptAsync to include an optional args parameter.
Ginger/.../Selenium/SeleniumDriver.cs Modified DoDragAndDrop to use Selenium’s Actions class and added DoDragandDropByOffSet for offset-based actions.
Ginger/.../ActUIElement.cs Updated enum member DragDropSelenium description from "Using Selenium" to "Using Web Driver".
Ginger/.../Playwright/PlaywrightDriver.cs Added new operations (DragDrop, MultiSetValue, DrawObject) to the supported actions list.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant H as ActUIElementHandler
    participant IE as IBrowserElement
    participant D as Driver (Selenium/Playwright)

    U->>H: Invoke HandleAsync(DragDrop)
    H->>H: Determine target method (coordinates vs. element)
    alt Coordinates provided
         H->>IE: DragDropXYCordinateAsync(x, y)
    else Element provided
         H->>IE: DragDropAsync(targetElement) or DragDropJSAsync(targetElement)
    end
    IE->>D: Execute drag-and-drop action via driver
    D-->>IE: Return status/result
    IE-->>H: Relay operation status
    H-->>U: Return final result
Loading
sequenceDiagram
    participant U as User
    participant H as ActUIElementHandler
    participant IE as IBrowserElement

    U->>H: Invoke HandleAsync(MultiSetValue)
    H->>IE: Retrieve all matching elements
    loop For each element
         IE->>IE: Clear and set new value
    end
    H-->>U: Return operation outcome
Loading

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

I’m a rabbit with code in my heart,
Hopping through async flows from the start.
Drag and drop, draw with flair and art,
Multi-set values—each piece played its part.
In this garden of code, I cheer with delight,
Come join the fun under the moonlight! 🐇💻


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: 6

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

1-11084: 🛠️ Refactor suggestion

Consider breaking down this large file into smaller, more focused components.

This file is over 11,000 lines long, which makes it difficult to maintain and understand. Consider splitting it into smaller, more focused classes following the Single Responsibility Principle:

  • Browser management
  • Element location
  • Element interaction
  • Network monitoring
  • JavaScript execution
  • Screenshot handling
// Example structure:
+ namespace GingerCore.Drivers {
+   public class SeleniumBrowserManager { /* Browser lifecycle management */ }
+   public class SeleniumElementLocator { /* Element location logic */ }
+   public class SeleniumElementInteractor { /* Element interaction */ } 
+   public class SeleniumNetworkMonitor { /* Network monitoring */ }
+   public class SeleniumJavaScriptExecutor { /* JS execution */ }
+   public class SeleniumScreenshotManager { /* Screenshot handling */ }
+ }

1002-1161: 🛠️ Refactor suggestion

Improve error handling in configChromeDriverAndStart method.

The error handling in this method could be improved to provide more specific error messages and proper cleanup:

private void configChromeDriverAndStart(ChromeOptions options) {
    try {
        // Existing configuration code
    }
    catch (Exception ex) {
-       if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && 
-           ex.Message.Contains("no such file or directory"))
+       if (ex is WebDriverException webDriverEx) {
+           HandleWebDriverException(webDriverEx);
+       }
+       else if (ex is ChromeNotFoundException) {
+           HandleChromeNotFoundException();
+       }
        throw;
    }
    finally {
+       CleanupDriverResources();
    }
}

6789-6814: ⚠️ Potential issue

Potential security vulnerability in JavaScript execution.

The code executes JavaScript without proper sanitization of input, which could lead to XSS attacks:

- ((IJavaScriptExecutor)Driver).ExecuteScript(script, Params);
+ // Sanitize script input
+ if (!IsScriptSafe(script)) {
+     throw new SecurityException("Potentially unsafe script detected");
+ }
+ ((IJavaScriptExecutor)Driver).ExecuteScript(SanitizeScript(script), Params);

479-496: 🧹 Nitpick (assertive)

Add retry mechanism for driver initialization.

The driver initialization lacks a proper retry mechanism for transient failures:

public override void InitDriver(Agent agent) {
+   int maxRetries = 3;
+   int retryCount = 0;
+   while (retryCount < maxRetries) {
        try {
            // Existing initialization code
+           break;
        }
        catch (WebDriverException ex) {
+           retryCount++;
+           if (retryCount == maxRetries) throw;
+           Thread.Sleep(1000 * retryCount); // Exponential backoff
        }
    }
}

10897-10899: 🧹 Nitpick (assertive)

Improve error logging with structured logging.

The error logging could be improved with more structured information:

- Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
+ Reporter.ToLog(eLogLevel.ERROR, new { 
+     Method = MethodBase.GetCurrentMethod().Name,
+     Error = ex.Message,
+     StackTrace = ex.StackTrace,
+     Context = new { BrowserType = mBrowserType, IsHeadless = HeadlessBrowserMode }
+ });

1379-1415: 🛠️ Refactor suggestion

Add proper resource cleanup in CloseDriver method.

The CloseDriver method should ensure proper cleanup of all resources:

public override void CloseDriver() {
    try {
+       // Dispose network monitoring resources
+       if (interceptor != null) {
+           interceptor.StopMonitoring().Wait();
+           interceptor = null;
+       }

+       // Dispose DevTools session
+       if (devToolsSession != null) {
+           devToolsSession.Dispose();
+           devToolsSession = null;
+       }

        // Existing cleanup code
    }
    finally {
+       // Ensure all resources are released
+       GC.Collect();
+       GC.WaitForPendingFinalizers();
    }
}

6997-7024: 🧹 Nitpick (assertive)

Optimize element locator performance.

The element location strategy could be optimized for better performance:

private List<ElementLocator> GetLocatorlistforFriendlyLocator(...) {
+   // Cache frequently used locators
+   private static readonly ConcurrentDictionary<string, ElementLocator> _locatorCache 
+       = new ConcurrentDictionary<string, ElementLocator>();

    // Existing code
+   string cacheKey = $"{currentHtmlNode.XPath}_{position}";
+   return _locatorCache.GetOrAdd(cacheKey, key => {
        // Existing locator creation logic
    });
}

10030-10064: 🛠️ Refactor suggestion

Add input validation for element info updates.

The UpdateElementInfoFields method needs better input validation:

void IWindowExplorer.UpdateElementInfoFields(ElementInfo EI) {
+   if (EI == null) throw new ArgumentNullException(nameof(EI));
+   if (Driver == null) throw new InvalidOperationException("Driver not initialized");

    // Validate element object
+   if (!(EI.ElementObject is IWebElement webElement)) {
+       throw new ArgumentException("Invalid element object type");
+   }

    // Existing update logic
}

1-17: 🧹 Nitpick (assertive)

Update license header with current year.

The license header should be updated to reflect the current year:

- Copyright © 2014-2024 European Support Limited
+ Copyright © 2014-2025 European Support Limited
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8d32ac and 9846682.

📒 Files selected for processing (7)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (4 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserElement.cs (2 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (3 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1 hunks)
  • Ginger/GingerCoreNET/GeneralLib/JavaScriptHandler.cs (1 hunks)
  • Ginger/GingerCoreNET/GingerCoreNET.csproj (1 hunks)
  • Ginger/GingerCoreNET/Resources/JavaScripts/draganddrop_playwright.js (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (1)
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#4058
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs:648-649
Timestamp: 2025-01-16T04:09:15.662Z
Learning: The Ginger project primarily targets .NET 8.0, which supports C# 12 features including collection expressions with spread operator.
🔇 Additional comments (10)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (4)

22-22: New import is consistent with usage.
This added namespace reference appears necessary for accessing JavaScriptHandler or related classes.


194-202: Add appropriate test coverage for new actions.
The newly introduced DragDrop, DrawObject, and MultiSetValue cases look good. Ensure corresponding automated tests are in place to verify their functionality.


244-251: Method is straightforward and clean.
DrawObjectAsync() correctly retrieves the element and calls DrawObjectAsync() on it. If no element is found, an exception is thrown upstream.


883-883: No additional logic to review.
This line merely closes the method block. Nothing else changed.

Ginger/GingerCoreNET/Resources/JavaScripts/draganddrop_playwright.js (1)

1-90: 🧹 Nitpick (assertive)

Fix copyright symbol and ensure cross-browser compatibility.
The functionality appears solid for a manual drag-and-drop simulation. However, “�” should be replaced with “©”. Also, confirm that all required browsers support the generated events.

Proposed fix:

- Copyright �
+ Copyright ©

Likely an incorrect or invalid review comment.

Ginger/GingerCoreNET/GeneralLib/JavaScriptHandler.cs (1)

32-32: New enum entry is well-integrated.
draganddrop_playwright extends support for the new JS file. No issues found.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserElement.cs (2)

65-67: LGTM! New UI interaction methods are well-defined.

The new asynchronous methods for drawing and drag-drop operations follow consistent naming conventions and have clear, descriptive signatures.


76-76: LGTM! ExecuteJavascriptAsync signature enhancement.

The addition of an optional nullable args parameter enhances JavaScript execution flexibility while maintaining backward compatibility.

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

813-835: LGTM! JavaScript execution enhancement is well-implemented.

The changes to support optional arguments in JavaScript execution are implemented consistently for both locator and element handle versions.

Ginger/GingerCoreNET/GingerCoreNET.csproj (1)

214-214: New Embedded Resource for Playwright Drag-and-Drop Simulation Added.
The addition of the embedded resource line

<EmbeddedResource Include="Resources\JavaScripts\draganddrop_playwright.js" />

ensures that the new JavaScript file required for simulating drag-and-drop operations via Playwright is included in the assembly. Please verify that the file exists in the specified location and that any corresponding usage in the code (such as in the UI element handler) properly references this resource.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 83acfc6 and 1f1b507.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (8 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (1)
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#4058
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs:648-649
Timestamp: 2025-01-16T04:09:15.662Z
Learning: The Ginger project primarily targets .NET 8.0, which supports C# 12 features including collection expressions with spread operator.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (1)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:622-652
Timestamp: 2025-02-17T12:22:22.732Z
Learning: Playwright's IElementHandle does not support drag-drop operations (DragToAsync). Only ILocator provides drag-drop functionality, so operations should throw InvalidOperationException when attempted with element handles.
🔇 Additional comments (8)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (3)

194-202: New UI element actions look consistent.
Adding DragDrop, DrawObject, and MultiSetValue cases helps extend functionality. Ensure that you have corresponding coverage in either automated tests or integration tests to confirm correctness.


244-251: DrawObjectAsync usage is straightforward.
Implementation appears consistent with the rest of the handler. No issues found.


253-299: Validate the drag-and-drop script usage & naming consistency.
The mix of “Selenium” and “JS” references for drag-drop might be confusing in a Playwright-oriented flow. The logic itself seems sound, but ensure all needed references (e.g., draganddrop_playwright script) are tested on all targeted browsers. Also, consider clarifying the naming for DragDropSelenium to avoid implying Selenium in a Playwright context.

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

20-20: Dependency import is valid.
Importing Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web.Exceptions appears relevant here for throwing InvalidActionConfigurationException. No issues found.


85-85: New overloaded click method is consistent.
Providing an overload that accepts System.Drawing.Point is well aligned with the existing pattern of locator vs. element-handle usage. Looks good.


618-623: DragDropAsync method: handling element locator is consistent.
Throwing when _playwrightLocator is null is consistent with the approach elsewhere. Ensure you have test coverage for the case where _playwrightElementHandle was used to construct this object (which will raise the InvalidOperationException).


669-709: Coordinate-based drag-and-drop logic is clear.
Manually computing the center X/Y and performing mouse actions is a valid workaround since Playwright’s element-handle drag is not supported. No immediate issues noted.


816-838: JavaScript execution with optional args is versatile.
Be mindful of potential injection risks if script or args originate from untrusted sources. Consider adding a validation step or usage guidelines to avoid accidental security issues.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f1b507 and cff7dc8.

📒 Files selected for processing (2)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (8 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (1)
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#4058
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs:648-649
Timestamp: 2025-01-16T04:09:15.662Z
Learning: The Ginger project primarily targets .NET 8.0, which supports C# 12 features including collection expressions with spread operator.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (1)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:622-652
Timestamp: 2025-02-17T12:22:22.732Z
Learning: Playwright's IElementHandle does not support drag-drop operations (DragToAsync). Only ILocator provides drag-drop functionality, so operations should throw InvalidOperationException when attempted with element handles.
🔇 Additional comments (9)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (4)

21-21: No concerns regarding this import.
It seems consistent with the existing usage, and there's no indication from static analysis or logs suggesting it's unused.


193-201: New cases look well-structured.
These additional switch cases for DragDrop, DrawObject, and MultiSetValue logically trigger the corresponding async methods.


243-250: Method call is straightforward.
This direct call to DrawObjectAsync on the first matching element aligns with the new action introduced for drawing. No issues found.


252-298: Ensure consistent error logging or re-throws.
The logic for drag-and-drop is clear. The method properly handles XY-based and element-based targets. The final catch just rethrows the exception, which is consistent with other patterns in this file.

If you’d like more detailed logs, you could optionally catch and log the exception before rethrowing, but that’s not strictly required.

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

20-20: Import usage is consistent.
This import for InvalidActionConfigurationException is relevant to the new drag/drop logic. No issues found.


618-660: Drag-drop feature aligns with Playwright usage.
The method correctly checks for _playwrightLocator and then delegates to DragDropAsync(IPlaywrightLocator, IBrowserElement), throwing if the locator is null. This is a sensible approach, given that Playwright's element handle does not support direct drag-and-drop.


662-674: Helper method is clear and consistent.
This utility method returns the _playwrightLocator from another PlaywrightBrowserElement. Proper fallback is to return null otherwise.


676-716: Coordinate-based drag-drop logic appears accurate.
Center calculation via bounding box, then mouseDown → mouseMove → mouseUp is standard. The error message if bounding box is missing is also helpful.


823-845: Extended JavaScript executor with optional arguments.
Adding an args parameter to the overloaded ExecuteJavascriptAsync methods expands flexibility. This aligns with the new DragDropJS approach in the handler.

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

♻️ Duplicate comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (1)

214-241: 🧹 Nitpick (assertive)

Be cautious with rethrowing masked exceptions
Catching all exceptions and throwing a generic InvalidActionConfigurationException might obscure the real error cause. Consider logging or preserving original exception details for easier troubleshooting.

catch (Exception ex)
{
-    throw new InvalidActionConfigurationException($"Multi set value operation cancelled.");
+    throw new InvalidActionConfigurationException(
+        $"MultiSetValueAsync failed: {ex.Message}", ex);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cff7dc8 and ee7cd99.

📒 Files selected for processing (3)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (8 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserElement.cs (2 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (1)
Learnt from: IamRanjeetSingh
PR: Ginger-Automation/Ginger#4058
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs:648-649
Timestamp: 2025-01-16T04:09:15.662Z
Learning: The Ginger project primarily targets .NET 8.0, which supports C# 12 features including collection expressions with spread operator.
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs (1)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4107
File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightBrowserElement.cs:622-652
Timestamp: 2025-02-17T12:22:22.732Z
Learning: Playwright's IElementHandle does not support drag-drop operations (DragToAsync). Only ILocator provides drag-drop functionality, so operations should throw InvalidOperationException when attempted with element handles.
🔇 Additional comments (9)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActUIElementHandler.cs (3)

193-201: New UI element actions are well-defined
The addition of DragDrop, DrawObject, and MultiSetValue cases improves feature coverage. Ensure unit tests are added for each new action to confirm correct behavior.


243-251: DrawObject operation might need exception handling
If GetFirstMatchingElementAsync() returns null, calling await element.DrawObjectAsync() will fail. Validate the element's existence after retrieval.


881-881: Line change confirmation
No functional change appears here; verify that the updated bracket doesn’t affect code flow.

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

617-662: JavaScript-based drag-drop
Using custom dispatchEvent(DragEvent, ...) calls is effective. Be sure it aligns with the supported browsers and that fallback logic is present for older browsers if required by your project.


707-719: Clear naming
GetElementLocator(IBrowserElement element) is straightforward. Ensure a helpful error message or logs exist if the returned locator is null to aid debugging.


721-761: Coordinate-based drag-drop
Coordinates for drag-and-drop are computed from the bounding box center. Confirm that fractional offsets (floats) are rounded consistently across browsers.


868-889: Optional arguments in ExecuteJavascriptAsync
The addition of object? args = null is a good extension. Double-check that all call sites properly handle default arguments.

Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserElement.cs (2)

65-68: New methods for graphical interactions
The additions of DrawObjectAsync(), DragDropAsync(...), DragDropJSAsync(...), and DragDropXYCordinateAsync(...) boost functionality. Ensure each method is implemented consistently across all driver classes.


77-77: ExecuteJavascriptAsync signature extension
Allowing optional arguments (object? args = null) is a solid improvement. Verify calls across the codebase use the updated signature.

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