Skip to content

Commit

Permalink
Merge branch 'Releases/Official-Release' into POMNotFoundFix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maheshkale447 authored Jul 14, 2022
2 parents 2d4de62 + 6f598c1 commit a33039b
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 143 deletions.
3 changes: 2 additions & 1 deletion Ginger/GingerAutoPilot/APIModelLib/SwaggerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ private void GenerateResponse(SwaggerOperation operation, ApplicationAPIModel ba
basicModal.ReturnValues.Add(arv);
}
}
else if (basicModal.ContentType == ApplicationAPIUtils.eContentType.JSon)
else if (basicModal.ContentType == ApplicationAPIUtils.eContentType.JSon ||
basicModal.ContentType == ApplicationAPIUtils.eContentType.FormData)
{
ApplicationAPIModel JsonResponseModel = new ApplicationAPIModel();
var i = GenerateJsonBody(JsonResponseModel, schemaObj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,10 @@ public void Execute(IVisualTestingDriver driver)
{
mDriver = driver;
CheckSetVisualAnalyzer();
CheckSetAppWindowSize();
if (mDriver.GetType().Name == "SeleniumDriver")
{
CheckSetAppWindowSize();
}
if (Amdocs.Ginger.Common.Context.GetAsContext(Context).Activity == null)
{
Amdocs.Ginger.Common.Context.GetAsContext(Context).Activity = ((Drivers.DriverBase)mDriver).BusinessFlow.CurrentActivity;
Expand Down
261 changes: 131 additions & 130 deletions Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/ApplitoolsAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class ApplitoolsAnalyzer : IVisualAnalyzer
private string sessionID;

// We keep one static eyes so we can reuse across action and close when done, to support applitools behaviour
static Applitools.Images.Eyes mEyes = null;
//static Applitools.Images.Eyes mEyes = null;
static Eyes newmEyes = null;
static ClassicRunner runner = null;
string mAppName;
Expand Down Expand Up @@ -113,16 +113,16 @@ private void SetEyesMatchLevel()
switch (matchLevel)
{
case eMatchLevel.Content:
mEyes.MatchLevel = MatchLevel.Content;
//mEyes.MatchLevel = MatchLevel.Content;
break;
case eMatchLevel.Exact:
mEyes.MatchLevel = MatchLevel.Exact;
//mEyes.MatchLevel = MatchLevel.Exact;
break;
case eMatchLevel.Layout:
mEyes.MatchLevel = MatchLevel.Layout;
//mEyes.MatchLevel = MatchLevel.Layout;
break;
case eMatchLevel.Strict:
mEyes.MatchLevel = MatchLevel.Strict;
//mEyes.MatchLevel = MatchLevel.Strict;
break;
}
}
Expand All @@ -149,7 +149,7 @@ private void NewSetEyesMatchLevel()

void IVisualAnalyzer.Execute()
{
//TODO:Remove hardcoded string and use typeof
//TODO: Remove hardcoded string and use typeof
if (mDriver.GetType().Name == "SeleniumDriver")
{
switch (GetSelectedApplitoolsActionEnum())
Expand All @@ -169,145 +169,148 @@ void IVisualAnalyzer.Execute()
}
else
{
switch (GetSelectedApplitoolsActionEnum())
{
case eApplitoolsAction.OpenEyes:
EyesOpen();
break;

case eApplitoolsAction.Checkpoint:
Checkpoint();
break;

case eApplitoolsAction.CloseEyes:
CloseEyes();
break;
}
mAct.Error = "Not Implemented";
mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
//switch (GetSelectedApplitoolsActionEnum())
//{
// case eApplitoolsAction.OpenEyes:
// EyesOpen();
// break;

// case eApplitoolsAction.Checkpoint:
// Checkpoint();
// break;

// case eApplitoolsAction.CloseEyes:
// CloseEyes();
// break;
//}
}

}


void EyesOpen()
{
List<int> mResolution = new List<int>();
try
{
mEyes = new Applitools.Images.Eyes();
//List<int> mResolution = new List<int>();
//try
//{
// mEyes = new Applitools.Windows.Eyes();

// //TODO: set the proxy
// // IWebProxy p = WebRequest.DefaultWebProxy; // .GetSystemWebProxy();

// mAppName = mAct.GetInputParamCalculatedValue(ActVisualTesting.Fields.ApplitoolsParamApplicationName);
// mTestName = mAct.GetInputParamCalculatedValue(ActVisualTesting.Fields.ApplitoolsParamTestName);
// mAct.CheckSetAppWindowSize();
// mEyes.ApiKey = mDriver.GetApplitoolKey();
// mEyes.ServerUrl = string.IsNullOrEmpty(mDriver.GetApplitoolServerURL()) ? mEyes.ServerUrl : mDriver.GetApplitoolServerURL();
// OperatingSystem Os_info = System.Environment.OSVersion;
// mEyes.HostOS = Os_info.VersionString;
// mEyes.HostApp = mDriver is SeleniumDriver ? ((SeleniumDriver)mDriver).GetBrowserType().ToString() : mDriver.GetPlatform().ToString();
// //mEyes.AddProperty("Environment ID", mDriver.GetEnvironment());
// mResolution = mAct.GetWindowResolution();
// mEyes.Open(1,mAppName, mTestName, new System.Drawing.Size(mResolution[0], mResolution[1]));
//}
//catch (Exception ex)
//{
// if (mResolution != null && mResolution.Any() && mResolution[0] < 500)
// {
// mAct.Error += "Eyes Open Failed. Set Resolution having width more than 500px, Error: " + ex.Message;
// }
// else
// {
// mAct.Error += "Eyes Open Failed, Error: " + ex.Message;
// }
//}

//TODO: set the proxy
// IWebProxy p = WebRequest.DefaultWebProxy; // .GetSystemWebProxy();

mAppName = mAct.GetInputParamCalculatedValue(ActVisualTesting.Fields.ApplitoolsParamApplicationName);
mTestName = mAct.GetInputParamCalculatedValue(ActVisualTesting.Fields.ApplitoolsParamTestName);
mAct.CheckSetAppWindowSize();
mEyes.ApiKey = mDriver.GetApplitoolKey();
mEyes.ServerUrl = string.IsNullOrEmpty(mDriver.GetApplitoolServerURL()) ? mEyes.ServerUrl : mDriver.GetApplitoolServerURL();
OperatingSystem Os_info = System.Environment.OSVersion;
mEyes.HostOS = Os_info.VersionString;
mEyes.HostApp = mDriver is SeleniumDriver ? ((SeleniumDriver)mDriver).GetBrowserType().ToString() : mDriver.GetPlatform().ToString();
mEyes.AddProperty("Environment ID", mDriver.GetEnvironment());
mResolution = mAct.GetWindowResolution();
mEyes.Open(mAppName, mTestName, new System.Drawing.Size(mResolution[0], mResolution[1]));
}
catch (Exception ex)
{
if (mResolution != null && mResolution.Any() && mResolution[0] < 500)
{
mAct.Error += "Eyes Open Failed. Set Resolution having width more than 500px, Error: " + ex.Message;
}
else
{
mAct.Error += "Eyes Open Failed, Error: " + ex.Message;
}
}

}

private void Checkpoint()
{
if (mEyes == null)
{
mAct.Error = "Applitools Eyes is not opened";
mAct.ExInfo = "You require to add Eyes.Open Action on step before.";
return;
}
//if (mEyes == null)
//{
// mAct.Error = "Applitools Eyes is not opened";
// mAct.ExInfo = "You require to add Eyes.Open Action on step before.";
// return;
//}

SetEyesMatchLevel();
AppImage response = mEyes.CheckImage(mDriver.GetScreenShot());
mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
//SetEyesMatchLevel();
////AppImage response = mEyes.CheckImage(mDriver.GetScreenShot());
//mEyes.Check(mAct.ItemName,Target.Window().Fully());
//mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;

}

private void CloseEyes()
{

try
{
TestResults TR = mEyes.Close(false);
// Update results info into outputs

SaveApplitoolsImages(TR);
mAct.ExInfo = "URL to view results: " + TR.Url;
mAct.AddOrUpdateReturnParamActual("ResultsURL", TR.Url + "");
mAct.AddOrUpdateReturnParamActual("Steps", TR.Steps + "");
mAct.AddOrUpdateReturnParamActual("Mismatches", TR.Mismatches + "");
mAct.AddOrUpdateReturnParamActual("ExactMatches", TR.ExactMatches + "");
mAct.AddOrUpdateReturnParamActual("StrictMatches", TR.StrictMatches + "");
mAct.AddOrUpdateReturnParamActual("ContentMatches", TR.ContentMatches + "");
mAct.AddOrUpdateReturnParamActual("LayoutMatches", TR.LayoutMatches + "");
mAct.AddOrUpdateReturnParamActual("ExactMatches", TR.ExactMatches + "");
mAct.AddOrUpdateReturnParamActual("IsNew", TR.IsNew + "");

if (!TR.IsNew)
{
foreach (StepInfo step in TR.StepsInfo)
{
if (!step.HasCurrentImage)
{
mAct.AddOrUpdateReturnParamActual(step.Name, "Failed with Missing Image" + "");
}
else
{
mAct.AddOrUpdateReturnParamActual(step.Name, step.IsDifferent ? "Failed" : "Passed" + "");
}
}
}
mAct.AddOrUpdateReturnParamActual("IsNew", TR.IsNew + "");
if ((TR.Mismatches == 0 || TR.IsNew) && TR.Missing == 0)
{
mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
if (TR.IsNew)
{
mAct.ExInfo = "Created new baseline in Applitools.";
}
else
{
mAct.ExInfo = TR.Matches + " steps Matched with saved baseline in Applitools.";
}

}
else
{
mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
if (TR.Mismatches != 0)
{
mAct.Error = TR.Mismatches + " steps Mismatched with saved baseline image in Applitools. ";
}
if (TR.Missing != 0)
{
mAct.Error += TR.Missing + " steps missing current images.";
}
}
}
catch (Exception ex)
{
mAct.Error += "Eyes Close operation failed, Error: " + ex.Message;
}
finally
{
mEyes.AbortIfNotClosed();
}
//try
//{
// TestResults TR = mEyes.AbortIfNotClosed(); ;
// //Update results info into outputs

// SaveApplitoolsImages(TR);
// mAct.ExInfo = "URL to view results: " + TR.Url;
// mAct.AddOrUpdateReturnParamActual("ResultsURL", TR.Url + "");
// mAct.AddOrUpdateReturnParamActual("Steps", TR.Steps + "");
// mAct.AddOrUpdateReturnParamActual("Mismatches", TR.Mismatches + "");
// mAct.AddOrUpdateReturnParamActual("ExactMatches", TR.ExactMatches + "");
// mAct.AddOrUpdateReturnParamActual("StrictMatches", TR.StrictMatches + "");
// mAct.AddOrUpdateReturnParamActual("ContentMatches", TR.ContentMatches + "");
// mAct.AddOrUpdateReturnParamActual("LayoutMatches", TR.LayoutMatches + "");
// mAct.AddOrUpdateReturnParamActual("ExactMatches", TR.ExactMatches + "");
// mAct.AddOrUpdateReturnParamActual("IsNew", TR.IsNew + "");

// if (!TR.IsNew)
// {
// foreach (StepInfo step in TR.StepsInfo)
// {
// if (!step.HasCurrentImage)
// {
// mAct.AddOrUpdateReturnParamActual(step.Name, "Failed with Missing Image" + "");
// }
// else
// {
// mAct.AddOrUpdateReturnParamActual(step.Name, step.IsDifferent ? "Failed" : "Passed" + "");
// }
// }
// }
// mAct.AddOrUpdateReturnParamActual("IsNew", TR.IsNew + "");
// if ((TR.Mismatches == 0 || TR.IsNew) && TR.Missing == 0)
// {
// mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
// if (TR.IsNew)
// {
// mAct.ExInfo = "Created new baseline in Applitools.";
// }
// else
// {
// mAct.ExInfo = TR.Matches + " steps Matched with saved baseline in Applitools.";
// }

// }
// else
// {
// mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
// if (TR.Mismatches != 0)
// {
// mAct.Error = TR.Mismatches + " steps Mismatched with saved baseline image in Applitools. ";
// }
// if (TR.Missing != 0)
// {
// mAct.Error += TR.Missing + " steps missing current images.";
// }
// }
//}
//catch (Exception ex)
//{
// mAct.Error += "Eyes Close operation failed, Error: " + ex.Message;
//}
//finally
//{
// mEyes.AbortIfNotClosed();
//}
}

void NewEyesOpen()
Expand Down Expand Up @@ -530,7 +533,6 @@ private void SaveApplitoolsImages(TestResults testResult)
int numOfSteps = testResult.Steps;
DownloadImages(numOfSteps, testResult);
}

private String BakeURL(String sessionURL)
{
//Edit URL and prepare it to download images from report
Expand Down Expand Up @@ -612,15 +614,14 @@ private void setbatchID(TestResults testresult)
Match match = Regex.Match(URL, "^" + this.ServerURL + @"/app/batches/(?<batchId>\d+).*$");
this.batchID = match.Groups[1].Value;
}

private void setsessionID(TestResults testresult)
{
string URL = testresult.Url;
Match match = Regex.Match(URL, "^" + this.ServerURL + @"/app/batches/\d+/(?<sessionId>\d+).*$");
this.sessionID = match.Groups[1].Value;
}


private HttpResponseMessage runLongRequest(string URL)
{
var request = new HttpRequestMessage(HttpMethod.Get, URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ limitations under the License.
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.DevTools;
using Newtonsoft.Json;
using DevToolsSessionDomains = OpenQA.Selenium.DevTools.V96.DevToolsSessionDomains;
using DevToolsSessionDomains = OpenQA.Selenium.DevTools.V101.DevToolsSessionDomains;

namespace GingerCore.Drivers
{
Expand Down Expand Up @@ -8688,9 +8688,9 @@ private void SetUPDevTools(IWebDriver webDriver)
var devTool = webDriver as IDevTools;

//DevTool Session
devToolsSession = devTool.GetDevToolsSession(96);
var domains = devToolsSession.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V96.DevToolsSessionDomains>();
domains.Network.Enable(new OpenQA.Selenium.DevTools.V96.Network.EnableCommandSettings());
devToolsSession = devTool.GetDevToolsSession(101);
var domains = devToolsSession.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V101.DevToolsSessionDomains>();
domains.Network.Enable(new OpenQA.Selenium.DevTools.V101.Network.EnableCommandSettings());
}
public async Task GetNetworkLogAsync(IWebDriver webDriver, ActBrowserElement act)
{
Expand Down
Loading

0 comments on commit a33039b

Please sign in to comment.