public void CloseAgentNotRunningTest() { //Arrange ActAgentManipulation actAgentManipulation = new ActAgentManipulation(); actAgentManipulation.GetOrCreateInputParam(ActAgentManipulation.Fields.AgentManipulationActionType); actAgentManipulation.Active = true; AddApplicationAgent(); mGR.SetCurrentActivityAgent(); //Act mGR.RunAction(actAgentManipulation); //Assert Assert.AreEqual(eRunStatus.Passed, actAgentManipulation.Status, "Action Status"); Assert.IsTrue(actAgentManipulation.ExInfo.Contains("Agent is not running")); }
public static void ClassInit(TestContext context) { SeleniumDriver mDriver = null; mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Screen Shot Action"; mBF.Active = true; Activity activity = new Activity(); mBF.Activities.Add(activity); mBF.CurrentActivity = activity; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "WebApp" }); mBF.CurrentActivity.TargetApplication = "WebApp"; mDriver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome); mDriver.AutoDetect = true; mDriver.HttpServerTimeOut = 60; mDriver.StartDriver(); Agent a = new Agent(); a.Active = true; a.Driver = mDriver; a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "WebApp"; AA.Agent = a; mGR.ApplicationAgents.Add(AA); mGR.CurrentBusinessFlow = mBF; mGR.SetCurrentActivityAgent(); // use helper !!!! Reporter.ToLog(eLogLevel.DEBUG, "Creating the GingerCoreNET WorkSpace"); WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler(); WorkSpace.Init(WSEH); WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); }
public static void ClassInit(TestContext context) { Reporter.WorkSpaceReporter = new UnitTestWorkspaceReporter(); int port = SocketHelper.GetOpenPort(); // gingerGrid = WorkSpace.Instance.LocalGingerGrid; // new GingerGrid(port); gingerGrid = new GingerGrid(port); gingerGrid.Start(); // WorkSpace.Instance.LocalGingerGrid = gingerGrid; webPlatform = new WebPlatformServiceFake(); gingerNode = new GingerNode(webPlatform); gingerNode.StartGingerNode("WebPlatformServiceFake 1", SocketHelper.GetLocalHostIP(), port); // Wait for node to be connected. gingerNodeProxy = new GingerNodeProxy(gingerGrid.NodeList[0]); gingerNodeProxy.GingerGrid = gingerGrid; // GingerRunner gingerRunner = new GingerRunner(); agent = new Agent(); agent.GingerNodeProxy = gingerNodeProxy; agent.Platform = GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib.ePlatformType.Service; // agent.PluginId = "aa"; agent.ServiceId = "WebPlatformServiceFake"; agent.AgentType = Agent.eAgentType.Service; agent.DriverConfiguration = new Amdocs.Ginger.Common.ObservableList <DriverConfigParam>(); //agent.st // agent.StartDriver(); gingerNodeProxy.StartDriver(agent.DriverConfiguration); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Java Driver"; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "TestApp" }); Activity activity = new Activity(); activity.TargetApplication = "JavaTestApp"; mBF.Activities.Add(activity); mBF.CurrentActivity = activity; mGR.CurrentBusinessFlow = mBF; ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "JavaTestApp"; AA.Agent = agent; mGR.ApplicationAgents.Add(AA); mGR.SetCurrentActivityAgent(); }
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 SetEmulationDeviceNameTest() { //arrange Activity activity = new Activity(); mBF.Activities.Add(activity); mBF.CurrentActivity = activity; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "DeviceEmulation" }); mBF.CurrentActivity.TargetApplication = "DeviceEmulation"; var mDriver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome); mDriver.AutoDetect = true; mDriver.HttpServerTimeOut = 60; //Set emulation device name mDriver.EmulationDeviceName = "iPad"; mDriver.StartDriver(); Agent agent = new Agent(); agent.Active = true; agent.Driver = mDriver; agent.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents.Add(agent); ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "DeviceEmulation"; AA.Agent = agent; mGR.ApplicationAgents.Add(AA); mGR.CurrentBusinessFlow = mBF; mGR.CurrentBusinessFlow.CurrentActivity = activity; mGR.SetCurrentActivityAgent(); ActBrowserElement actBrowser = new ActBrowserElement(); actBrowser.ControlAction = ActBrowserElement.eControlAction.GotoURL; actBrowser.GetOrCreateInputParam("Value", "http://www.google.com"); actBrowser.Active = true; activity.Acts.Add(actBrowser); //act ActBrowserElement actBrowser2 = new ActBrowserElement(); actBrowser2.ControlAction = ActBrowserElement.eControlAction.RunJavaScript; actBrowser2.GetOrCreateInputParam("Value", "navigator.userAgent"); actBrowser2.Active = true; actBrowser2.AddNewReturnParams = true; activity.Acts.Add(actBrowser2); mGR.RunActivity(activity); //assert Assert.AreEqual(true, actBrowser2.ReturnValues.FirstOrDefault().Actual.Contains("iPad")); }