public void BizFlowSaveLoad() { //Arrange int ActivitiesToCreate = 5; //Act BusinessFlow BF = new BusinessFlow(); BF.Name = "Biz flow 1"; BF.Description = "Desc 1"; //BF.Status = BusinessFlow.eBusinessFlowStatus.Active; //TODOL do NOT write to XML if null or empty BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity(); a.ActivityName = "Activity number " + i; a.Description = "Desc - " + i; BF.Activities.Add(a); a.Status = eRunStatus.Passed; for (int j = 1; j <= 2; j++) { ActTextBox t = new ActTextBox(); t.Description = "Set text box " + j; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID" + j; a.Acts.Add(t); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL " + j; g.LocateValue = "ID" + j; a.Acts.Add(g); } } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); string FileName = TestResources.GetTempFile("bf1.xml"); BF.RepositorySerializer.SaveToFile(BF, FileName); // Assert NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer(); BusinessFlow BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), FileName); Assert.AreEqual(BF2.Name, BF.Name); Assert.AreEqual(BF2.Description, BF.Description); Assert.AreEqual(BF2.Activities.Count, ActivitiesToCreate); Assert.AreEqual(BF2.Variables.Count, 1); //Validations }
//----------------------------getAct... methods--------------------------------------------- //TODO:change to use ActUIElement private Act getActTextBox(IWebElement currentElement) { ActTextBox a = new ActTextBox(); setActLocator(currentElement, a); a.TextBoxAction = ActTextBox.eTextBoxAction.SetValue; a.Value = currentElement.GetAttribute("value"); a.AddOrUpdateReturnParamActual("Actual", "Tag Name = " + currentElement.TagName); return(a); }
public void BizFlowCheckIsDirtyTrue() { //Arrange int ActivitiesToCreate = 2; string TempFilepath = TestResources.GetTempFile("bfIsDirtyTrue.xml"); BusinessFlow BF = new BusinessFlow(); BF.Name = "Biz flow 1"; BF.Description = "Desc 1"; //BF.Status = BusinessFlow.eBusinessFlowStatus.Active; //TODOL do NOT write to XML if null or empty BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity(); a.ActivityName = "Activity number " + i; a.Description = "Desc - " + i; BF.Activities.Add(a); a.Status = eRunStatus.Passed; for (int j = 1; j <= 2; j++) { ActTextBox t = new ActTextBox(); t.Description = "Set text box " + j; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID" + j; a.Acts.Add(t); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL " + j; g.LocateValue = "ID" + j; a.Acts.Add(g); } } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); //Act BF.RepositorySerializer.SaveToFile(BF, TempFilepath); // Assert NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer(); BusinessFlow BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), TempFilepath); BF2.StartDirtyTracking(); BF2.Description = "aaa"; Assert.IsTrue(BF2.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified); }
public void BizFlowCheckIsDirtyTrue() { //Arrange int ActivitiesToCreate = 2; string TempFilepath = TestResources.GetTempFile("bfIsDirtyTrue.xml"); BusinessFlow BF = new BusinessFlow(); BF.Name = "Biz flow 1"; BF.Description = "Desc 1"; //BF.Status = BusinessFlow.eBusinessFlowStatus.Active; //TODOL do NOT write to XML if null or empty BF.Activities = new ObservableList <Activity>(); for (int i = 1; i <= ActivitiesToCreate; i++) { Activity a = new Activity(); a.ActivityName = "Activity number " + i; a.Description = "Desc - " + i; BF.Activities.Add(a); a.Status = eRunStatus.Passed; for (int j = 1; j <= 2; j++) { ActTextBox t = new ActTextBox(); t.Description = "Set text box " + j; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID" + j; a.Acts.Add(t); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL " + j; g.LocateValue = "ID" + j; a.Acts.Add(g); } } VariableString v = new VariableString(); v.Name = "Var1"; v.Description = "VDesc 1"; BF.AddVariable(v); //Act BF.SaveToFile(TempFilepath); // Assert BusinessFlow BF2 = (BusinessFlow)RepositoryItem.LoadFromFile(typeof(BusinessFlow), TempFilepath); BF2.SaveBackup();//dirty now just indicate if backup exist BF2.Description = "aaa"; Assert.IsTrue(BF2.IsDirty); }
public void Activity_With_Action_Pass() { //Arrange //string ParamName = "p1"; //ActGotoURL act1 = new ActGotoURL() { LocateBy = Act.eLocatorType.NA, Value = "https://ginger-automation.github.io/test.html", Active = true }; //act1.AddOrUpdateReturnParam(ParamName, "378"); //act1.AddOrUpdateExpectedParam(ParamName, "37"); // failed due to regex ////Act //mGR.CalculateActionFinalStatus(act1); ////Assert //// since there is no failure we assume pass //Assert.AreEqual(act1.Status, eRunStatus.Fail, "act1.Status=eRunStatus.Fail"); //ActReturnValue RV = act1.GetReturnValue(ParamName); //Assert.AreEqual(RV.Status, ActReturnValue.eStatus.Fail, "RV.Status, ActReturnValue.eStatus.Fail"); Activity a1 = new Activity(); a1.Active = true; mBF.Activities.Add(a1); ActGotoURL act1 = new ActGotoURL() { LocateBy = eLocateBy.NA, Value = "https://ginger-automation.github.io/test.html", Active = true }; a1.Acts.Add(act1); ActTextBox act2 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "UserName", Value = "Yaron", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act2); ActTextBox act3 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "Password", Value = "123456", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act3); mGR.RunRunner(); Assert.AreEqual(a1.Status, eRunStatus.Passed, "a1.Status=eRunStatus.Passed"); }
public void SpeedTest() { //Arrange ResetBusinessFlow(); Activity a0 = new Activity(); a0.Active = true; ActGotoURL act1 = new ActGotoURL() { LocateBy = eLocateBy.NA, Value = "https://ginger-automation.github.io/test.html", Active = true }; a0.Acts.Add(act1); mBF.Activities.Add(a0); Activity a1 = new Activity(); a1.Active = true; mBF.Activities.Add(a1); for (int i = 1; i < 10; i++) { ActTextBox act2 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "UserName", Value = "Yaron", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act2); ActTextBox act3 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "Password", Value = "123456", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act3); } mGR.RunRunner(); //Assert Assert.AreEqual(mBF.RunStatus, eRunStatus.Passed, "mBF.RunStatus"); Assert.AreEqual(mBF.Activities.Count(), (from x in mBF.Activities where x.Status == eRunStatus.Passed select x).Count(), "All activities should Passed"); Assert.IsTrue(a1.Elapsed < 10000, "a1.Elapsed Time less than 10000 ms"); }
public void ActivitiesClearBackup() { //Arrange BusinessFlow BF = new BusinessFlow(); string FileName = TestResources.GetTempFile("activityClearBackup.xml"); BF.Name = "Businessflow1"; BF.Description = "Test Clear Backup"; BF.Activities = new ObservableList <Activity>(); Activity a = new Activity() { ActivityName = "Activity 1", Description = "Desciption -1", Status = eRunStatus.Passed }; BF.Activities.Add(a); ActTextBox t = new ActTextBox() { Description = "Set text box ", LocateBy = eLocateBy.ByID, LocateValue = "ID" }; a.Acts.Add(t); //Act BF.RepositorySerializer.SaveToFile(BF, FileName); a.SaveBackup(); ActGotoURL g = new ActGotoURL() { Description = "goto URL ", LocateValue = "ID" }; a.Acts.Add(g); BF.RepositorySerializer.SaveToFile(BF, FileName); a.SaveBackup(); a.RestoreFromBackup(); NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer(); BusinessFlow BF2 = (BusinessFlow)newRepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), FileName); BF2.SaveBackup(); //dirty now just indicate if backup exist BF2.Description = "aaa"; // Assert Assert.AreEqual(BF2.Activities[0].Acts.Count, BF.Activities[0].Acts.Count); }
public void ActivitiesClearBackup() { //Arrange BusinessFlow BF = new BusinessFlow(); BF.Name = "Businessflow1"; BF.Description = "Test Clear Backup"; BF.Activities = new ObservableList <Activity>(); Activity a = new Activity(); a.ActivityName = "Activity 1"; a.Description = "Desciption -1"; BF.Activities.Add(a); a.Status = eRunStatus.Passed; ActTextBox t = new ActTextBox(); t.Description = "Set text box "; t.LocateBy = eLocateBy.ByID; t.LocateValue = "ID"; a.Acts.Add(t); //Act BF.SaveToFile(@"c:\temp\activityClearBackup.xml"); a.SaveBackup(); ActGotoURL g = new ActGotoURL(); g.Description = "goto URL "; g.LocateValue = "ID"; a.Acts.Add(g); BF.SaveToFile(@"c:\temp\activityClearBackup.xml"); a.SaveBackup(); a.RestoreFromBackup(); BusinessFlow BF2 = (BusinessFlow)RepositoryItem.LoadFromFile(typeof(BusinessFlow), @"c:\temp\activityClearBackup.xml"); BF2.SaveBackup();//dirty now just indicate if backup exist BF2.Description = "aaa"; // Assert Assert.AreEqual(BF2.Activities[0].Acts.Count, BF.Activities[0].Acts.Count); }
public void Activity_With_Action_Fail_And_RunOption_Continue() { Activity a1 = new Activity(); a1.Active = true; a1.ActionRunOption = Activity.eActionRunOption.ContinueActionsRunOnFailure; mBF.Activities.Add(a1); ActGotoURL act1 = new ActGotoURL() { LocateBy = eLocateBy.NA, Value = "https://ginger-automation.github.io/test.html", Active = true }; a1.Acts.Add(act1); //Intentionally put incorrect locate Value ActTextBox act2 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "UserName1", Value = "Yaron", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act2); ActTextBox act3 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "Password", Value = "123456", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act3); mGR.RunRunner(); Assert.AreEqual(a1.Status, eRunStatus.Failed, "a1.Status=eRunStatus.Failed"); Assert.AreEqual(act1.Status, eRunStatus.Passed, "act1.Status=eRunStatus.Passed"); Assert.AreEqual(act2.Status, eRunStatus.Failed, "act1.Status=eRunStatus.Failed"); Assert.AreEqual(act3.Status, eRunStatus.Passed, "act1.Status=eRunStatus.Passed"); }
private void AddActTextBox(ActTextBox act) { string s = GetDriverfindElem(act.LocateBy, act.LocateValue); switch (act.TextBoxAction) { case ActTextBox.eTextBoxAction.SetValue: case ActTextBox.eTextBoxAction.SetValueFast: s += ".SetValue(" + VE(act.Value) + ")"; break; case ActTextBox.eTextBoxAction.GetValue: s = "String actual = " + s + ".Value"; break; default: //temp to show something s += "." + Missing + act.TextBoxAction.ToString() + " " + act.Value; break; } s += ";"; WriteLine(s); }
public void SCM_Login() { //Arrange ResetBusinessFlow(); // mGR.SetSpeed(1); Activity a1 = new Activity(); a1.Active = true; a1.TargetApplication = "SCM"; mBF.Activities.Add(a1); ActGotoURL act1 = new ActGotoURL() { LocateBy = eLocateBy.NA, Value = "https://ginger-automation.github.io/test.html", Active = true }; a1.Acts.Add(act1); ActTextBox act2 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "UserName", Value = "Yaron", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act2); ActTextBox act3 = new ActTextBox() { LocateBy = eLocateBy.ByID, LocateValue = "Password", Value = "123456", TextBoxAction = ActTextBox.eTextBoxAction.SetValue, Active = true }; a1.Acts.Add(act3); ActSubmit act4 = new ActSubmit() { LocateBy = eLocateBy.ByValue, LocateValue = "Log in", Active = true }; a1.Acts.Add(act4); VariableString v1 = (VariableString)mBF.GetVariable("v1"); v1.Value = "123"; //Act mGR.RunRunner(); // mGR.CurrentBusinessFlow = mBF; // mGR.RunActivity(a1); //Assert Assert.AreEqual(mBF.RunStatus, eRunStatus.Passed); Assert.AreEqual(a1.Status, eRunStatus.Passed); Assert.AreEqual(act1.Status, eRunStatus.Passed); Assert.AreEqual(act2.Status, eRunStatus.Passed); Assert.AreEqual(act3.Status, eRunStatus.Passed); Assert.AreEqual(act4.Status, eRunStatus.Passed); Assert.AreEqual(v1.Value, "123"); }
public static HTMLReportPage GetSampleReportPage(string Xaml) { BusinessFlow BF1 = new BusinessFlow() { Name = "BF1 - Create Customer", Description = "Create any type of customer: Business/Residential..." }; BF1.Active = true; BF1.RunStatus = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed; BF1.Activities = new ObservableList <Activity>(); BF1.Elapsed = 2364; //Activity 1 Activity a1 = new Activity() { ActivityName = "Launch Application & Login", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed }; BF1.Activities.Add(a1); ActGotoURL act1 = new ActGotoURL() { Description = "Goto URL www.abcd.com", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed, Elapsed = 3124 }; a1.Acts.Add(act1); ActReturnValue ARV1 = new ActReturnValue(); ARV1.Param = "RC"; ARV1.Expected = "123"; ARV1.Actual = "123"; ARV1.Status = ActReturnValue.eStatus.Passed; act1.ReturnValues.Add(ARV1); ActTextBox act2 = new ActTextBox() { Description = "Enter User ID", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed, Elapsed = 230 }; // Add sample screen shot Bitmap tempBmp = new Bitmap(Ginger.Properties.Resources.ScreenShot1); act2.ScreenShots.Add(GingerCore.General.BitmapImageToFile(tempBmp)); a1.Acts.Add(act2); ActTextBox act3 = new ActTextBox() { Description = "Enter Password", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed, Elapsed = 112 }; a1.Acts.Add(act3); ActSubmit act4 = new ActSubmit() { Description = "Click Submit Button", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed, Elapsed = 1282 }; a1.Acts.Add(act4); //Activity 2 Activity a2 = new Activity() { ActivityName = "Create New customer", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed }; BF1.Activities.Add(a2); ActTextBox acta21 = new ActTextBox() { Description = "Enter First Name", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed, Elapsed = 325 }; a2.Acts.Add(acta21); ActTextBox acta22 = new ActTextBox() { Description = "Enter Last Name", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed, Elapsed = 302 }; a2.Acts.Add(acta22); ActTextBox acta23 = new ActTextBox() { Description = "Enter City", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed, Elapsed = 820, Error = "Error: Element not found by ID 'City'", ExInfo = "Cannot find element" }; a2.Acts.Add(acta23); ActSubmit acta24 = new ActSubmit() { Description = "Click Create Button", Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending }; a2.Acts.Add(acta24); //Add Variables BF1.Variables = new ObservableList <VariableBase>(); VariableString v1 = new VariableString() { Name = "FirstName", Value = "David Smith" }; BF1.Variables.Add(v1); VariableRandomNumber v2 = new VariableRandomNumber() { Name = "Random 1", Min = 1, Max = 100, Value = "55" }; BF1.Variables.Add(v2); //Add a few simple BFs BusinessFlow BF2 = new BusinessFlow() { Name = "BF2 - Customer Order Product", Description = "", Active = true }; BF2.Activities = new ObservableList <Activity>(); BF2.RunStatus = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed; BF2.Elapsed = 1249; ProjEnvironment env = new ProjEnvironment() { Name = "Env1" }; //TODO: add more env info //cretae dummy GR, GMR RunsetExecutor GMR = new RunsetExecutor(); GingerRunner GR = new GingerRunner(); GR.BusinessFlows.Add(BF1); GR.BusinessFlows.Add(BF2); GR.CurrentSolution = WorkSpace.UserProfile.Solution; GMR.Runners.Add(GR); ReportInfo RI = new ReportInfo(env, GMR); HTMLReportPage RP = new HTMLReportPage(RI, Xaml); return(RP); }