public void ActXMLProcessingTest() { //Arrange ActXMLProcessing action = new ActXMLProcessing(); var templateFile = TestResources.GetTestResourcesFile(@"XML\TemplateVU.xml"); action.GetOrCreateInputParam(ActXMLProcessing.Fields.TemplateFileName, templateFile); action.TemplateFileName.ValueForDriver = templateFile; var targetFile = TestResources.GetTestResourcesFile(@"XML\TargetFile.xml"); action.GetOrCreateInputParam(ActXMLProcessing.Fields.TargetFileName, targetFile); action.TargetFileName.ValueForDriver = targetFile; VariableString stringVar = new VariableString(); stringVar.Name = "env"; stringVar.Value = "xyz"; mBF.CurrentActivity.AddVariable(stringVar); ObservableList <ActInputValue> paramList = new ObservableList <ActInputValue>(); paramList.Add(new ActInputValue() { Param = "PAR_ENV", Value = "{Var Name=env}" }); paramList.Add(new ActInputValue() { Param = "PAR_USER", Value = "abc" }); paramList.Add(new ActInputValue() { Param = "PAR_PASS", Value = "abc123" }); paramList.Add(new ActInputValue() { Param = "PAR_BUCKET", Value = "pqrst" }); paramList.Add(new ActInputValue() { Param = "PAR_QUERY", Value = "test1234" }); action.DynamicElements = paramList; action.Active = true; action.AddNewReturnParams = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); //Assert Assert.AreEqual(eRunStatus.Passed, action.Status, "Action Status"); Assert.AreEqual(7, action.ReturnValues.Count); Assert.AreEqual("xyz", action.ReturnValues[0].Actual); Assert.AreEqual(action.Error, null, "Act.Error"); }
public void RunDisabledActionTest() { //Arrange Activity activity = GetActivityFromRepository(); ObservableList <IAct> actionList = activity.Acts; Act action = (Act)actionList[0]; action.Active = false; //Act mGR.RunAction(action); //Assert Assert.AreEqual(action.Status, Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped); Assert.AreEqual("Action is not active.", action.ExInfo); }
public void GotoURLGrid() { //Arrange string url = "aaa"; ActBrowserElement actBrowserElement = new ActBrowserElement(); actBrowserElement.ControlAction = ActBrowserElement.eControlAction.GotoURL; actBrowserElement.Value = url; mBF.CurrentActivity.Acts.Add(actBrowserElement); mBF.CurrentActivity.Acts.CurrentItem = actBrowserElement; //ACT mGR.RunAction(actBrowserElement, false); //Assert Assert.IsTrue(string.IsNullOrEmpty(actBrowserElement.Error), "No Error"); Assert.IsTrue(actBrowserElement.ExInfo.Contains("Navigated to: " + url), "ExInfo"); }
public static void ClassInit(TestContext context) { WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler(); WorkSpace.Init(WSEH); // launch PB Test App if (proc == null || proc.HasExited) { proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = @"pb_test_app.exe"; proc.StartInfo.WorkingDirectory = TestResources.GetTestResourcesFolder("PBTestApp"); Console.WriteLine(proc.StartInfo.WorkingDirectory); Console.WriteLine(proc.StartInfo.FileName); proc.Start(); GingerCore.General.DoEvents(); GingerCore.General.DoEvents(); } mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test PB Driver"; Platform p = new Platform(); p.PlatformType = ePlatformType.PowerBuilder; mBF.TargetApplications.Add(new TargetApplication() { AppName = "PBTestAPP" }); Activity activity = new Activity(); activity.TargetApplication = "PBTestApp"; mBF.Activities.Add(activity); mBF.CurrentActivity = activity; mDriver = new PBDriver(mBF); mDriver.StartDriver(); Agent a = new Agent(); a.Active = true; a.Driver = mDriver; a.DriverType = Agent.eDriverType.PowerBuilder; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "PBTestApp"; AA.Agent = a; mGR.ApplicationAgents.Add(AA); mGR.CurrentBusinessFlow = mBF; mGR.SetCurrentActivityAgent(); // Do Switch Window, to be ready for actions ActSwitchWindow c = new ActSwitchWindow(); c.LocateBy = eLocateBy.ByTitle; c.LocateValueCalculated = "Simple Page"; c.WaitTime = 10; mDriver.RunAction(c); //if(c.Status.Value==eRunStatus.Failed) //{ // c = new ActSwitchWindow(); // c.LocateBy = eLocateBy.ByTitle; // c.LocateValueCalculated = "Simple Page"; // c.WaitTime = 10; // mDriver.RunAction(c); //} ActPBControl action = new ActPBControl(); action.LocateBy = eLocateBy.ByXPath; action.ControlAction = ActPBControl.eControlAction.SetValue; action.AddNewReturnParams = true; action.Wait = 4; action.LocateValueCalculated = "/[AutomationId:1001]"; action.Value = proc.StartInfo.WorkingDirectory = TestResources.GetTestResourcesFolder("PBTestApp") + @"\Browser.html"; action.Active = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); action = new ActPBControl(); action.LocateBy = eLocateBy.ByName; action.ControlAction = ActPBControl.eControlAction.SetValue; action.LocateValueCalculated = "Launch Widget Window"; action.Active = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); c = new ActSwitchWindow(); c.LocateBy = eLocateBy.ByTitle; c.LocateValueCalculated = "CSM Widgets Test Applicaiton"; c.WaitTime = 10; mDriver.RunAction(c); string actual = ""; do { action = new ActPBControl(); action.LocateBy = eLocateBy.ByName; action.ControlAction = ActPBControl.eControlAction.IsExist; action.LocateValueCalculated = "Script Error"; action.AddNewReturnParams = true; action.Timeout = 10; action.Active = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); Assert.AreEqual(action.Status, eRunStatus.Passed, "Action Status"); actual = action.GetReturnParam("Actual"); if (actual.Equals("True")) { ActPBControl PbAct = new ActPBControl(); PbAct.LocateBy = eLocateBy.ByXPath; PbAct.ControlAction = ActPBControl.eControlAction.Click; PbAct.LocateValueCalculated = @"/Script Error/[LocalizedControlType:title bar]/Close"; PbAct.Active = true; mBF.CurrentActivity.Acts.Add(PbAct); mBF.CurrentActivity.Acts.CurrentItem = PbAct; mGR.RunAction(PbAct, false); } } while (actual.Equals("True")); //proceed for switch window and initialize browser c = new ActSwitchWindow(); c.LocateBy = eLocateBy.ByTitle; c.LocateValueCalculated = "CSM Widgets Test Applicaiton"; c.WaitTime = 2; mDriver.RunAction(c); int count = 1; ActBrowserElement actBrowser = new ActBrowserElement(); do { actBrowser.LocateBy = eLocateBy.ByXPath; actBrowser.LocateValue = @"/[AutomationId:1000]/[LocalizedControlType:pane]/[LocalizedControlType:pane]/[LocalizedControlType:pane]"; actBrowser.ControlAction = ActBrowserElement.eControlAction.InitializeBrowser; actBrowser.Wait = 2; actBrowser.Timeout = 10; actBrowser.Active = true; mBF.CurrentActivity.Acts.Add(actBrowser); mBF.CurrentActivity.Acts.CurrentItem = actBrowser; mGR.RunAction(actBrowser, false); count--; } while (actBrowser.Status.Equals(eRunStatus.Failed) && count > 0); if (actBrowser.Status.Equals(eRunStatus.Failed)) { Assert.AreEqual(actBrowser.Status, eRunStatus.Passed, "actBrowser.Status"); Assert.AreEqual(actBrowser.Error, null, "actBrowser.Error"); } }
public void SetValue_textbox() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.SetValue; act.LocateValueCalculated = "firstName"; act.Value = "Ginger"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.GetValue; act.LocateValueCalculated = "firstName"; act.AddNewReturnParams = true; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "Ginger", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
public void TakeScreenShotAction() { //Arrange ActScreenShot action = new ActScreenShot(); action.SaveToFileName = TestResources.GetTestResourcesFolder("ScreenShot"); action.TakeScreenShot = true; action.Active = true; action.WindowsToCapture = Act.eWindowsToCapture.OnlyActiveWindow; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); //Assert Assert.AreEqual(eRunStatus.Passed, action.Status, "Action Status"); //Delete folder files System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(TestResources.GetTestResourcesFolder("ScreenShot")); FileInfo[] files = di.GetFiles("*.jpg").Where(p => p.Extension == ".jpg").ToArray(); foreach (System.IO.FileInfo file in files) { try { file.Attributes = FileAttributes.Normal; File.Delete(file.FullName); } catch (Exception e) { throw new Exception("Error:", e); } } }