Skip to content

Commit

Permalink
For WindowExplorer currently below features are functional
Browse files Browse the repository at this point in the history
1. TreeView
2. LiveSpy
3. PageSource
For VisualTesting action currently below features are functional,
1. Visual Regression Testing
2. Applitools
  • Loading branch information
IamRanjeetSingh committed Jul 23, 2024
1 parent 9076eff commit 72351b9
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public override void RunAction(Act act)
ActGotoURLHandler actGotoURLHandler = new(actGotoURL, _browser);
actGotoURLHandler.HandleAsync().Wait();
break;
case ActVisualTesting actVisualTesting:
actVisualTesting.Execute(this);
break;
default:
act.Error = $"This Action is not supported for Playwright driver";
break;
Expand Down Expand Up @@ -223,6 +226,10 @@ public bool IsActionSupported(Act act, out string message)
{
return true;
}
else if (act is ActVisualTesting)
{
return true;
}
else
{
message = $"'{act.ActionType}' is not supported by Playwright driver, use Selenium driver instead.";
Expand Down Expand Up @@ -731,13 +738,14 @@ public List<ElementInfo> GetElementChildren(ElementInfo elementInfo)
{
await SwitchToFrameOfElementAsync(elementInfo);
string xpath = GenerateXPathFromHTMLElementInfo(htmlElementInfo);
IEnumerable<IBrowserElement> browserElements = await _browser.CurrentWindow.CurrentTab.GetElementsAsync(eLocateBy.ByXPath, xpath);
string childrenXPath = GenerateChildrenXPath(xpath);
IEnumerable<IBrowserElement> browserElements = await _browser.CurrentWindow.CurrentTab.GetElementsAsync(eLocateBy.ByXPath, childrenXPath);
List<HTMLElementInfo> htmlElements = [];
foreach (IBrowserElement browserElement in browserElements)
{
HTMLElementInfo newHtmlElement = await CreateHtmlElementAsync(browserElement);

if (string.IsNullOrEmpty(newHtmlElement.ID))
if (string.IsNullOrEmpty(newHtmlElement.ID) && htmlElementInfo.HTMLElementObject != null)
{
newHtmlElement.ID = htmlElementInfo.HTMLElementObject.Id;
}
Expand Down Expand Up @@ -767,6 +775,27 @@ public List<ElementInfo> GetElementChildren(ElementInfo elementInfo)
}).Result;
}

private string GenerateChildrenXPath(string parentXPath)
{
string[] parentXPathSegments = parentXPath.Split("/", StringSplitOptions.RemoveEmptyEntries);
string elementType = parentXPathSegments[^1];

int index = elementType.IndexOf("[");
if (index != -1)
{
elementType = elementType.Substring(0, index);
}

if (elementType == "iframe" || elementType == "frame")
{
return "/html/*";
}
else
{
return parentXPath + "/*";
}
}

public ObservableList<ControlProperty> GetElementProperties(ElementInfo elementInfo)
{
if (elementInfo is not HTMLElementInfo htmlElementInfo)
Expand Down

0 comments on commit 72351b9

Please sign in to comment.