Skip to content

Multi POM Fixed#4172

Merged
Maheshkale447 merged 3 commits into
Releases/Betafrom
BugFix/MultiPOMHungIssueFixed
Apr 9, 2025
Merged

Multi POM Fixed#4172
Maheshkale447 merged 3 commits into
Releases/Betafrom
BugFix/MultiPOMHungIssueFixed

Conversation

@prashelke

@prashelke prashelke commented Apr 9, 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
    • Introduced an automatic saving mechanism to ensure updates are retained.
    • Enhanced execution workflows to run asynchronously with improved error handling for a smoother user experience.
    • Improved visibility control handling to ensure proper functionality under different thread states.

@coderabbitai

coderabbitai Bot commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change updates the POMObjectMappingWithRunsetWizardPage class. In the TestElementButtonClicked method, a formatting adjustment was made along with additional logic to retrieve and save modified POMs when specific conditions are met. The ExecuteRunSet method was revised to run its execution code within a Task.Run() block, incorporating a try-catch to properly log exceptions during the execution of the runset.

Changes

File Change Summary
Ginger/.../POMObjectMappingWithRunsetWizardPage.xaml.cs Modified TestElementButtonClicked: adjusted spacing in condition and added code to retrieve & save modified POMs. Updated ExecuteRunSet: wrapped execution in Task.Run() with try-catch error handling.
Ginger/.../SeleniumDriver.cs Updated GetVisibleControls: added null check for tagLocator before setting Active to false, removed commented-out code handling STA state.

Possibly related PRs

  • MultiPOM Design changes #4161: Involved similar modifications to the TestElementButtonClicked and ExecuteRunSet methods, impacting the same class structure and underlying logic.

Suggested reviewers

  • Maheshkale447

Poem

I'm a merry rabbit, swift and bright,
Hopping through code with pure delight.
Saving POMs and running tasks in style,
Error logs vanish, making me smile.
With every change, my code hops free—
A joyful leap in our tech jubilee! 🐰🌟


📜 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 d91363d and d1c5a46.

📒 Files selected for processing (1)
  • Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (2)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-04-08T10:41:31.325Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: amitamir
PR: Ginger-Automation/Ginger#4151
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:409-0
Timestamp: 2025-04-08T10:41:40.827Z
Learning: In the Ginger project, utility methods that are shared between multiple CLI components should be added to the CLIHelper class, which serves as a central location for common functionality used across different CLI handler classes.
🧬 Code Graph Analysis (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (5)
Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs (1)
  • WorkSpace (62-1016)
Ginger/GingerCoreNET/Application Models/Execution/POM/POMExecutionUtils.cs (1)
  • ApplicationPOMModel (66-78)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs (3)
  • Task (481-489)
  • Task (1232-1245)
  • Task (3658-3667)
Ginger/GingerCoreNET/Run/RunsetExecutor.cs (1)
  • RunsetExecutor (49-1054)
🔇 Additional comments (2)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (2)

22-22: Appropriate import added for SaveHandler usage.

The Amdocs.Ginger.CoreNET.GeneralLib namespace is correctly added to support the SaveHandler class used in the code modifications at lines 278-286.


351-362:

Details

✅ Verification successful

Effective use of Task.Run with proper exception handling.

The execution of the runset has been properly encapsulated within a Task.Run() block with try-catch error handling. This change enhances error handling during runset execution and improves UI responsiveness by running the execution on a background thread.


🏁 Script executed:

#!/bin/bash
# Check for similar execution patterns in other parts of the codebase
rg -A 2 -B 2 "await Task.Run\(\(\) =>" --type csharp

Length of output: 55945


Consistent Task.Run Pattern with Proper Exception Handling Confirmed

The implementation in POMObjectMappingWithRunsetWizardPage.xaml.cs (lines 351-362) correctly encapsulates the runset execution within a Task.Run() block using a try-catch for error logging. A repository-wide scan confirms that this pattern is consistently applied in similar contexts, ensuring both enhanced error handling and improved UI responsiveness.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 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 a548c0e and 0683b9c.

📒 Files selected for processing (1)
  • Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (2)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-04-08T10:41:31.325Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: amitamir
PR: Ginger-Automation/Ginger#4151
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:409-0
Timestamp: 2025-04-08T10:41:40.827Z
Learning: In the Ginger project, utility methods that are shared between multiple CLI components should be added to the CLIHelper class, which serves as a central location for common functionality used across different CLI handler classes.
🧬 Code Graph Analysis (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (4)
Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs (1)
  • WorkSpace (62-1016)
Ginger/GingerCoreNET/Application Models/Execution/POM/POMExecutionUtils.cs (1)
  • ApplicationPOMModel (66-78)
Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs (3)
  • Task (481-489)
  • Task (1232-1245)
  • Task (3658-3667)
Ginger/GingerCoreNET/Run/RunsetExecutor.cs (1)
  • RunsetExecutor (49-1054)
🔇 Additional comments (2)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (2)

22-22: Approve import addition.

The import for Amdocs.Ginger.CoreNET.GeneralLib is required to access the SaveHandler class used for saving modified POMs later in the file.


232-232: Formatting improvement.

The code formatting has been improved by adding a space after the if keyword, which aligns with standard code style conventions.

@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

♻️ Duplicate comments (2)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (2)

279-287: 🛠️ Refactor suggestion

Replace First() with FirstOrDefault() for safer POM retrieval.

Using First() will throw an exception if no matching POM is found. Although you're checking for AutoUpdatedPOMList.Contains() first, it's more robust to use FirstOrDefault() with a proper null check.

-var aPOMModified = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<ApplicationPOMModel>().First(aPOM => aPOM.Guid == elem.ApplicationAPIModel.Guid);
-if(aPOMModified != null)
+var aPOMModified = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<ApplicationPOMModel>().FirstOrDefault(aPOM => aPOM.Guid == elem.ApplicationAPIModel.Guid);
+if (aPOMModified != null)
 {
     SaveHandler.Save(aPOMModified);
 }
 else
 {
     Reporter.ToLog(eLogLevel.ERROR, $"Cannot find POM with GUID '{elem.ApplicationAPIModel.Guid}' to save");
 }

Additionally, there's a spacing issue in your if condition that should be fixed.


351-364: 🛠️ Refactor suggestion

Simplify Task.Run implementation and properly handle async calls.

Your implementation runs the Execute method in a background thread, but there are two issues:

  1. You're not awaiting the async Execute method inside the Task.Run
  2. There are redundant try-catch blocks with the same error message
-
-await Task.Run(() =>
-{
-    try
-    {
-        Execute(WorkSpace.Instance.RunsetExecutor);
-    }
-    catch (Exception ex)
-    {
-        // Handle the exception
-        Reporter.ToLog(eLogLevel.ERROR, "Exception occurred while Execute RunSet", ex);
-    }
-});
-
+await Task.Run(async () =>
+{
+    try
+    {
+        await Execute(WorkSpace.Instance.RunsetExecutor);
+    }
+    catch (Exception ex)
+    {
+        Reporter.ToLog(eLogLevel.ERROR, "Exception occurred while Execute RunSet", ex);
+    }
+});

This change makes the lambda async, properly awaits the Execute call, and removes the redundant outer try-catch block.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0683b9c and d91363d.

📒 Files selected for processing (2)
  • Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (5 hunks)
  • Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (2)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs:21-21
Timestamp: 2025-04-08T10:41:31.325Z
Learning: The `Amdocs.Ginger.Common.SourceControlLib` namespace is required in files that reference the `GingerSolution` class for source control operations in the Ginger automation framework.
Learnt from: amitamir
PR: Ginger-Automation/Ginger#4151
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:409-0
Timestamp: 2025-04-08T10:41:40.827Z
Learning: In the Ginger project, utility methods that are shared between multiple CLI components should be added to the CLIHelper class, which serves as a central location for common functionality used across different CLI handler classes.
🧬 Code Graph Analysis (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/UpdateMultipleWizard/POMObjectMappingWithRunsetWizardPage.xaml.cs (3)
Ginger/GingerCoreNET/Application Models/Execution/POM/POMExecutionUtils.cs (1)
  • ApplicationPOMModel (66-78)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
Ginger/GingerCoreNET/Run/RunsetExecutor.cs (1)
  • RunsetExecutor (49-1054)
🔇 Additional comments (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs (1)

5289-5292: Good defensive programming practice added.

Adding the null check before accessing the tagLocator.Active property prevents potential NullReferenceException if no locator with ByTagName exists. This makes the code more robust and safer.

@prashelke
prashelke requested a review from Maheshkale447 April 9, 2025 14:56
@Maheshkale447
Maheshkale447 merged commit 11b6552 into Releases/Beta Apr 9, 2025
@Maheshkale447
Maheshkale447 deleted the BugFix/MultiPOMHungIssueFixed branch April 9, 2025 15:05
@coderabbitai coderabbitai Bot mentioned this pull request Apr 25, 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