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

Playwright Defect fix D43161_D43162_D44142_D44141 #4017

Merged
merged 7 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,16 @@ void SetPlatformBasedUIUpdates()
inputPar.Value = "false";
}
}

(DefaultAction as ActUIElement).ElementData = mElementInfo.GetElementData();
DefaultAction.Description = string.Format("{0} : {1} - {2}", (DefaultAction as ActUIElement).ElementAction, mElementInfo.ElementTypeEnum.ToString(), mElementInfo.ElementName);
if(DefaultAction is ActUIElement)
{
(DefaultAction as ActUIElement).ElementData = mElementInfo.GetElementData();
DefaultAction.Description = string.Format("{0} : {1} - {2}", (DefaultAction as ActUIElement).ElementAction, mElementInfo.ElementTypeEnum.ToString(), mElementInfo.ElementName);
}
else if(DefaultAction is ActBrowserElement)
{
DefaultAction.Description = string.Format("{0} : {1} - {2}", (DefaultAction as ActBrowserElement).ControlAction, mElementInfo.ElementTypeEnum.ToString(), mElementInfo.ElementName);
}

SetActionDetails(DefaultAction);
actEditPage = new ActionEditPage(DefaultAction, General.eRIPageViewMode.Explorer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ private async Task HandleRunJavaScriptAsync()
/// </summary>
private async Task HandleAsyncClickAsync()
{
await _browserTab.StartListenDialogsAsync();
string script = "element => setTimeout(function() { element.click(); }, 100);";
IBrowserElement element = await GetFirstMatchingElementAsync();
await element.ExecuteJavascriptAsync(script);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public string CreateNetworkLogFile(string Filename, List<Tuple<string, object>>
System.IO.Directory.CreateDirectory(FullDirectoryPath);
}

FullFilePath = $"FullDirectoryPath{Path.PathSeparator}{Filename}_{DateTime.Now.Day.ToString() }_{ DateTime.Now.Month.ToString() }_{ DateTime.Now.Year.ToString() }_{DateTime.Now.Millisecond.ToString()}.har";
FullFilePath = $"{FullDirectoryPath}{Path.DirectorySeparatorChar}{Filename}_{DateTime.Now.Day.ToString() }_{ DateTime.Now.Month.ToString() }_{ DateTime.Now.Year.ToString() }_{DateTime.Now.Millisecond.ToString()}.har";
if (!System.IO.File.Exists(FullFilePath))
{
string FileContent = JsonConvert.SerializeObject(networkLogList.Select(x => x.Item2).ToList());
Expand Down
2 changes: 2 additions & 0 deletions Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/IBrowserTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ internal interface IBrowserTab
public Task<AxeResult?> TestAccessibilityAsync(AxeRunOptions? options = null);

public Task CloseAsync();

public Task StartListenDialogsAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ internal sealed class PlaywrightBrowserTab : IBrowserTab
List<Tuple<string, object>> networkRequestLogList;
ActBrowserElement _act;
public bool isNetworkLogMonitoringStarted = false;
public bool isDialogDismiss = true;
IDialog dialogs;

public bool IsClosed => _isClosed;
Expand All @@ -91,6 +92,7 @@ private void RemoveEventHandlers()
{
_playwrightPage.Console -= OnConsoleMessage;
_playwrightPage.Close -= OnPlaywrightPageClose;
_playwrightPage.Dialog -= OnPlaywrightDialog;
}

private void OnPlaywrightPageClose(object? sender, IPlaywrightPage e)
Expand Down Expand Up @@ -746,7 +748,7 @@ private async void OnNetworkRequestSent(object? sender, IRequest request)
{
try
{
if (_BrowserHelper.ShouldMonitorAllUrls() || _BrowserHelper.ShouldMonitorUrl( request.Url))
if (_BrowserHelper.ShouldMonitorAllUrls() || _BrowserHelper.ShouldMonitorUrl(request.Url))
{
networkRequestLogList.Add(new Tuple<string, object>($"RequestUrl:{ request.Url}", JsonConvert.SerializeObject(request, Formatting.Indented,
new JsonSerializerSettings
Expand All @@ -769,7 +771,6 @@ private async void OnNetworkRequestSent(object? sender, IRequest request)
/// <param name="response"></param>
private async void OnNetworkResponseReceived(object? sender, IResponse response)
{
await response.FinishedAsync();
try
{
if (response != null)
Expand Down Expand Up @@ -807,15 +808,23 @@ private async void OnNetworkResponseReceived(object? sender, IResponse response)
}
}







private async void OnPlaywrightDialog(object? sender, IDialog e)
{
try
{
dialogs = e;
if (isDialogDismiss)
{
await e.DismissAsync();
}
else
{
dialogs = e;
}

}
catch (Exception ex)
{
Expand All @@ -833,6 +842,7 @@ public async Task AcceptMessageBox()
if (dialogs != null)
{
await dialogs.AcceptAsync();
isDialogDismiss = true;
}
else
{
Expand All @@ -856,6 +866,7 @@ public async Task DismissMessageBox()
if (dialogs != null)
{
await dialogs.DismissAsync();
isDialogDismiss = true;
}
else
{
Expand Down Expand Up @@ -906,6 +917,7 @@ public async Task SetMessageBoxText(string MessageBoxText)
if (dialogs != null)
{
await dialogs.AcceptAsync(promptText: MessageBoxText);
isDialogDismiss = true;
}
else
{
Expand All @@ -919,6 +931,11 @@ public async Task SetMessageBoxText(string MessageBoxText)
}

}

public async Task StartListenDialogsAsync()
{
isDialogDismiss = false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11093,7 +11093,7 @@ private void OnNetworkRequestSent(object sender, NetworkRequestSentEventArgs e)
{
try
{
if (_BrowserHelper.ShouldMonitorAllUrls() || _BrowserHelper.ShouldMonitorUrl( e.RequestUrl))
if (_BrowserHelper.ShouldMonitorAllUrls() || _BrowserHelper.ShouldMonitorUrl(e.RequestUrl))
prashelke marked this conversation as resolved.
Show resolved Hide resolved
{
networkRequestLogList.Add(new Tuple<string, object>($"RequestUrl: {e.RequestUrl}", JsonConvert.SerializeObject(e, Formatting.Indented)));
}
Expand Down
Loading