-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4010 from Ginger-Automation/Feature/Playwright_Ex…
…tentedSupport Playwright Extended Support for Network Log ,Alert message and interp…
- Loading branch information
Showing
6 changed files
with
656 additions
and
125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/BrowserHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using amdocs.ginger.GingerCoreNET; | ||
using Amdocs.Ginger.Common; | ||
using GingerCore.Actions; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web | ||
{ | ||
internal class BrowserHelper | ||
{ | ||
private readonly ActBrowserElement _act; | ||
public BrowserHelper(ActBrowserElement act) { | ||
_act = act; | ||
} | ||
|
||
public bool ShouldMonitorAllUrls() | ||
{ | ||
return _act.GetOrCreateInputParam(nameof(ActBrowserElement.eMonitorUrl)).Value == nameof(ActBrowserElement.eMonitorUrl.AllUrl); | ||
} | ||
|
||
public bool ShouldMonitorUrl(string requestUrl) | ||
{ | ||
return _act.GetOrCreateInputParam(nameof(ActBrowserElement.eMonitorUrl)).Value == nameof(ActBrowserElement.eMonitorUrl.SelectedUrl) | ||
&& _act.UpdateOperationInputValues != null | ||
&& _act.UpdateOperationInputValues.Any(x => !string.IsNullOrEmpty(x.ValueForDriver) && requestUrl.ToLower().Contains(x.ValueForDriver.ToLower())); | ||
} | ||
|
||
public string CreateNetworkLogFile(string Filename, List<Tuple<string, object>> networkLogList) | ||
{ | ||
if (string.IsNullOrEmpty(Filename)) | ||
{ | ||
Reporter.ToLog(eLogLevel.INFO, $"Method - {MethodBase.GetCurrentMethod().Name}, Filename should not be empty"); | ||
} | ||
|
||
if (networkLogList == null) | ||
{ | ||
Reporter.ToLog(eLogLevel.INFO, $"Method - {MethodBase.GetCurrentMethod().Name}, networkLogList should not be empty"); | ||
} | ||
string FullFilePath = string.Empty; | ||
try | ||
{ | ||
string FullDirectoryPath = System.IO.Path.Combine(WorkSpace.Instance.Solution.Folder, "Documents", "NetworkLog"); | ||
if (!System.IO.Directory.Exists(FullDirectoryPath)) | ||
{ | ||
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"; | ||
if (!System.IO.File.Exists(FullFilePath)) | ||
{ | ||
string FileContent = JsonConvert.SerializeObject(networkLogList.Select(x => x.Item2).ToList()); | ||
|
||
using (Stream fileStream = System.IO.File.Create(FullFilePath)) | ||
{ | ||
fileStream.Close(); | ||
} | ||
System.IO.File.WriteAllText(FullFilePath, FileContent); | ||
} | ||
} | ||
catch(Exception ex) | ||
{ | ||
Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name} Error: {ex.Message}", ex); | ||
} | ||
return FullFilePath; | ||
|
||
|
||
} | ||
} | ||
} |
Oops, something went wrong.