Skip to content

Commit

Permalink
Updated Code According code rabbit suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
prashelke committed Nov 28, 2024
1 parent 0393cdd commit 4d77b16
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ private async Task HandleStopMonitoringNetworkLogOperationAsync()
{
try
{
((PlaywrightBrowserTab)_browser!.CurrentWindow.CurrentTab).StopCaptureNetworkLog(_act);
await ((PlaywrightBrowserTab)_browser!.CurrentWindow.CurrentTab).StopCaptureNetworkLog(_act);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.
using GingerCore.Actions;
using Microsoft.Playwright;
using Newtonsoft.Json;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
Expand Down Expand Up @@ -693,7 +694,7 @@ await Task.Run(() =>
/// </summary>
/// <param name="act"></param>

public async void StopCaptureNetworkLog(ActBrowserElement act)
public async Task StopCaptureNetworkLog(ActBrowserElement act)
{
try
{
Expand Down Expand Up @@ -770,7 +771,7 @@ private async void OnNetworkResponseReceived(object? sender, IResponse response)
await response.FinishedAsync();
try
{
if (response.BodyAsync() != null)
if (response != null)
{
string monitorType = _act.GetOrCreateInputParam(nameof(ActBrowserElement.eMonitorUrl)).Value;
if (_BrowserHelper.IsToMonitorAllUrls(_act) || _BrowserHelper.IsToMonitorOnlySelectedUrls(_act,response.Url))
Expand Down Expand Up @@ -813,9 +814,7 @@ private async void OnPlaywrightDialog(object? sender, IDialog e)
{
try
{
await Task.Run(() => {
dialogs = e;
});
dialogs = e;
}
catch (Exception ex)
{
Expand All @@ -830,7 +829,14 @@ public async Task AcceptMessageBox()
{
try
{
await dialogs.AcceptAsync();
if (dialogs != null)
{
await dialogs.AcceptAsync();
}
else
{
Reporter.ToLog(eLogLevel.WARN, "No dialog to accept.");
}
}
catch (Exception ex)
{
Expand All @@ -846,8 +852,15 @@ public async Task DismissMessageBox()
{
try
{
await dialogs.DismissAsync();

if (dialogs != null)
{
await dialogs.DismissAsync();
}
else
{
Reporter.ToLog(eLogLevel.WARN, "No dialog to dismiss.");
}

}
catch (Exception ex)
{
Expand All @@ -863,7 +876,15 @@ public string GetMessageBoxText()
{
try
{
return dialogs.Message;
if (dialogs != null)
{
return dialogs.Message;
}
else
{
Reporter.ToLog(eLogLevel.WARN, "No dialog to get message.");
return string.Empty;
}
}
catch (Exception ex)
{
Expand All @@ -881,7 +902,15 @@ public async Task SetMessageBoxText(string MessageBoxText)
{
try
{
await dialogs.AcceptAsync(promptText:MessageBoxText);
if (dialogs != null)
{
await dialogs.AcceptAsync(promptText: MessageBoxText);
}
else
{
Reporter.ToLog(eLogLevel.WARN, "No dialog to accept.");

}
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10933,8 +10933,6 @@ public async Task GetNetworkLogAsync(ActBrowserElement act)
{
try
{
await Task.Run(() =>
{
if (isNetworkLogMonitoringStarted)
{
act.AddOrUpdateReturnParamActual("Raw Request", Newtonsoft.Json.JsonConvert.SerializeObject(networkRequestLogList.Select(x => x.Item2).ToList()));
Expand All @@ -10954,7 +10952,6 @@ await Task.Run(() =>
act.ExInfo = $"Action is skipped,{nameof(ActBrowserElement.eControlAction.StartMonitoringNetworkLog)} Action is not started";
act.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped;
}
});
}
catch(Exception ex)
{
Expand Down

0 comments on commit 4d77b16

Please sign in to comment.