-
Notifications
You must be signed in to change notification settings - Fork 62
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
Enhancement - Playwright Window Explorer And Visual Testing Action Support #3850
Enhancement - Playwright Window Explorer And Visual Testing Action Support #3850
Conversation
1. TreeView 2. LiveSpy 3. PageSource For VisualTesting action currently below features are functional, 1. Visual Regression Testing 2. Applitools
WalkthroughThe recent changes to the Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
Files selected for processing (1)
- 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#3783 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:129-129 Timestamp: 2024-06-24T08:39:59.351Z Learning: User IamRanjeetSingh has indicated that the `RunAction` method in the `PlaywrightDriver` class should remain synchronous due to current constraints in the codebase.
Learnt from: GokulBothe99 PR: Ginger-Automation/Ginger#3835 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:1022-1029 Timestamp: 2024-07-18T09:05:15.264Z Learning: The user prefers readability over concise code in the context of deactivating locators in the `LearnElementInfoDetails` method of the `PlaywrightDriver` class.
Additional comments not posted (4)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (4)
229-232
: LGTM!The new case for
ActVisualTesting
is correctly implemented in theIsActionSupported
method.
741-748
: LGTM!The
GetElementChildren
method has been correctly updated to use the newGenerateChildrenXPath
method.
778-797
: LGTM!The new
GenerateChildrenXPath
method is correctly implemented and handles specific cases foriframe
andframe
elements.
164-166
: LGTM! But verify the usage ofActVisualTesting
.The new case for
ActVisualTesting
is correctly implemented.However, ensure that all instances of
ActVisualTesting
are correctly handled in the codebase.Verification successful
LGTM! But verify the usage of
ActVisualTesting
.The new case for
ActVisualTesting
is correctly implemented.All instances of
ActVisualTesting
are correctly handled in the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances of `ActVisualTesting` in the codebase. # Test: Search for the usage of `ActVisualTesting`. Expect: Only valid instances. rg --type cs -A 5 $'ActVisualTesting'Length of output: 52539
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
Outdated
Show resolved
Hide resolved
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
Outdated
Show resolved
Hide resolved
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
Files selected for processing (1)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (5 hunks)
Additional context used
Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2)
Learnt from: IamRanjeetSingh PR: Ginger-Automation/Ginger#3783 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:129-129 Timestamp: 2024-06-24T08:39:59.351Z Learning: User IamRanjeetSingh has indicated that the `RunAction` method in the `PlaywrightDriver` class should remain synchronous due to current constraints in the codebase.
Learnt from: GokulBothe99 PR: Ginger-Automation/Ginger#3835 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:1022-1029 Timestamp: 2024-07-18T09:05:15.264Z Learning: The user prefers readability over concise code in the context of deactivating locators in the `LearnElementInfoDetails` method of the `PlaywrightDriver` class.
Additional comments not posted (4)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (4)
164-166
: LGTM! Ensure proper testing for the new action type.The addition of the
ActVisualTesting
case is correct. Ensure that this new action type is properly tested.
178-178
: LGTM!The addition of
ActVisualTesting
in the supported actions is correct.
733-734
: LGTM!The usage of the new method
GenerateChildrenXPath
improves the specificity of element retrieval.
770-789
: LGTM!The method
GenerateChildrenXPath
is correctly implemented to handle specific cases foriframe
andframe
elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (5 hunks)
Additional context used
Learnings (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (2)
Learnt from: IamRanjeetSingh PR: Ginger-Automation/Ginger#3783 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:129-129 Timestamp: 2024-06-24T08:39:59.351Z Learning: User IamRanjeetSingh has indicated that the `RunAction` method in the `PlaywrightDriver` class should remain synchronous due to current constraints in the codebase.
Learnt from: GokulBothe99 PR: Ginger-Automation/Ginger#3835 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:1022-1029 Timestamp: 2024-07-18T09:05:15.264Z Learning: The user prefers readability over concise code in the context of deactivating locators in the `LearnElementInfoDetails` method of the `PlaywrightDriver` class.
else if (act is ActVisualTesting actVisualTesting) | ||
{ | ||
return true; | ||
message = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead."; | ||
return actVisualTesting.VisualTestingAnalyzer == ActVisualTesting.eVisualTestingAnalyzer.VRT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper support check for ActVisualTesting
.
The check for ActVisualTesting
is added, but the error message is hardcoded. Consider using a more dynamic approach to handle unsupported analyzers.
- message = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead.";
+ message = $"The Visual Testing Analyzer '{actVisualTesting.VisualTestingAnalyzer}' is not supported by the Playwright driver. Please use the Selenium driver instead.";
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.
else if (act is ActVisualTesting actVisualTesting) | |
{ | |
return true; | |
message = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead."; | |
return actVisualTesting.VisualTestingAnalyzer == ActVisualTesting.eVisualTestingAnalyzer.VRT; | |
message = $"The Visual Testing Analyzer '{actVisualTesting.VisualTestingAnalyzer}' is not supported by the Playwright driver. Please use the Selenium driver instead."; |
case ActVisualTesting actVisualTesting: | ||
if (actVisualTesting.VisualTestingAnalyzer == ActVisualTesting.eVisualTestingAnalyzer.VRT) | ||
{ | ||
actVisualTesting.Execute(this); | ||
} | ||
else | ||
{ | ||
act.Error = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead."; | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper handling of ActVisualTesting
.
The new case for ActVisualTesting
is added, but the error message is hardcoded. Consider using a more dynamic approach to handle unsupported analyzers.
- act.Error = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead.";
+ act.Error = $"The Visual Testing Analyzer '{actVisualTesting.VisualTestingAnalyzer}' is not supported by the Playwright driver. Please use the Selenium driver instead.";
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 ActVisualTesting actVisualTesting: | |
if (actVisualTesting.VisualTestingAnalyzer == ActVisualTesting.eVisualTestingAnalyzer.VRT) | |
{ | |
actVisualTesting.Execute(this); | |
} | |
else | |
{ | |
act.Error = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead."; | |
} | |
break; | |
case ActVisualTesting actVisualTesting: | |
if (actVisualTesting.VisualTestingAnalyzer == ActVisualTesting.eVisualTestingAnalyzer.VRT) | |
{ | |
actVisualTesting.Execute(this); | |
} | |
else | |
{ | |
act.Error = $"The Visual Testing Analyzer '{actVisualTesting.VisualTestingAnalyzer}' is not supported by the Playwright driver. Please use the Selenium driver instead."; | |
} | |
break; |
private string GenerateChildrenXPath(string parentXPath) | ||
{ | ||
string[] parentXPathSegments = parentXPath.Split("/", StringSplitOptions.RemoveEmptyEntries); | ||
string elementType = parentXPathSegments[^1]; | ||
|
||
int index = elementType.IndexOf('['); | ||
if (index != -1) | ||
{ | ||
elementType = elementType.AsSpan(0, index).ToString(); | ||
} | ||
|
||
if (string.Equals(elementType, "iframe") || string.Equals(elementType, "frame")) | ||
{ | ||
return "/html/*"; | ||
} | ||
else | ||
{ | ||
return parentXPath + "/*"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize the XPath generation logic.
The method generates XPath for child elements but can be optimized for readability and performance.
- string[] parentXPathSegments = parentXPath.Split("/", StringSplitOptions.RemoveEmptyEntries);
- string elementType = parentXPathSegments[^1];
- int index = elementType.IndexOf('[');
- if (index != -1)
- {
- elementType = elementType.AsSpan(0, index).ToString();
- }
- if (string.Equals(elementType, "iframe") || string.Equals(elementType, "frame"))
- {
- return "/html/*";
- }
- else
- {
- return parentXPath + "/*";
- }
+ var elementType = parentXPath.Split("/", StringSplitOptions.RemoveEmptyEntries).Last().Split('[').First();
+ return (elementType.Equals("iframe", StringComparison.OrdinalIgnoreCase) || elementType.Equals("frame", StringComparison.OrdinalIgnoreCase))
+ ? "/html/*"
+ : $"{parentXPath}/*";
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.
private string GenerateChildrenXPath(string parentXPath) | |
{ | |
string[] parentXPathSegments = parentXPath.Split("/", StringSplitOptions.RemoveEmptyEntries); | |
string elementType = parentXPathSegments[^1]; | |
int index = elementType.IndexOf('['); | |
if (index != -1) | |
{ | |
elementType = elementType.AsSpan(0, index).ToString(); | |
} | |
if (string.Equals(elementType, "iframe") || string.Equals(elementType, "frame")) | |
{ | |
return "/html/*"; | |
} | |
else | |
{ | |
return parentXPath + "/*"; | |
} | |
} | |
private string GenerateChildrenXPath(string parentXPath) | |
{ | |
var elementType = parentXPath.Split("/", StringSplitOptions.RemoveEmptyEntries).Last().Split('[').First(); | |
return (elementType.Equals("iframe", StringComparison.OrdinalIgnoreCase) || elementType.Equals("frame", StringComparison.OrdinalIgnoreCase)) | |
? "/html/*" | |
: $"{parentXPath}/*"; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/GingerWebDriver.cs (3 hunks)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (6 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)
Common learnings
Learnt from: GokulBothe99 PR: Ginger-Automation/Ginger#3835 File: Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs:1022-1029 Timestamp: 2024-07-18T09:05:15.264Z Learning: The user prefers readability over concise code in the context of deactivating locators in the `LearnElementInfoDetails` method of the `PlaywrightDriver` class.
Additional comments not posted (1)
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/GingerWebDriver.cs (1)
528-531
: LGTM!The new properties
Width
,Height
,X
, andY
are correctly incorporated into theHTMLElementInfo
object.
Size size = await browserElement.SizeAsync(); | ||
Point position = await browserElement.PositionAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper error handling for asynchronous calls.
The asynchronous calls to SizeAsync
and PositionAsync
should include error handling to manage potential exceptions that may arise.
- Size size = await browserElement.SizeAsync();
- Point position = await browserElement.PositionAsync();
+ Size size;
+ try {
+ size = await browserElement.SizeAsync();
+ } catch (Exception ex) {
+ // Handle or log the exception as needed
+ throw new InvalidOperationException("Failed to retrieve size.", ex);
+ }
+
+ Point position;
+ try {
+ position = await browserElement.PositionAsync();
+ } catch (Exception ex) {
+ // Handle or log the exception as needed
+ throw new InvalidOperationException("Failed to retrieve position.", ex);
+ }
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.
Size size = await browserElement.SizeAsync(); | |
Point position = await browserElement.PositionAsync(); | |
Size size; | |
try { | |
size = await browserElement.SizeAsync(); | |
} catch (Exception ex) { | |
// Handle or log the exception as needed | |
throw new InvalidOperationException("Failed to retrieve size.", ex); | |
} | |
Point position; | |
try { | |
position = await browserElement.PositionAsync(); | |
} catch (Exception ex) { | |
// Handle or log the exception as needed | |
throw new InvalidOperationException("Failed to retrieve position.", ex); | |
} |
There was a problem hiding this 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
Files selected for processing (1)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs
For WindowExplorer, currently below features are functional with Playwright Driver
For VisualTesting action currently below features are functional with Playwright Driver
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
HTMLElementInfo
with spatial data.Improvements