private void XTargetApplicationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (mWizard.mPomLearnUtils.POM.TargetApplicationKey != null) { mAppPlatform = WorkSpace.Instance.Solution.GetTargetApplicationPlatform(mWizard.mPomLearnUtils.POM.TargetApplicationKey); } else { if (xTargetApplicationComboBox.SelectedItem is ApplicationPlatform selectedplatform) { mAppPlatform = selectedplatform.Platform; } } mWizard.OptionalAgentsList = GingerCore.General.ConvertListToObservableList((from x in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<Agent>() where x.Platform == mAppPlatform select x).ToList()); foreach (Agent agent in mWizard.OptionalAgentsList) { if (agent.AgentOperations == null) { AgentOperations agentOperations = new AgentOperations(agent); agent.AgentOperations = agentOperations; } agent.Tag = string.Empty; } GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xAgentControlUC, ucAgentControl.SelectedAgentProperty, mWizard.mPomLearnUtils, nameof(mWizard.mPomLearnUtils.Agent)); xAgentControlUC.Init(mWizard.OptionalAgentsList); xAgentControlUC.PropertyChanged -= XAgentControlUC_PropertyChanged; xAgentControlUC.PropertyChanged += XAgentControlUC_PropertyChanged; PlatformSpecificUIManipulations(); AddValidations(); }
public static void AddApplicationAgent() { Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "Web" }); Agent a = new Agent(); AgentOperations agentOperations = new AgentOperations(a); a.AgentOperations = agentOperations; a.DriverType = Agent.eDriverType.SeleniumChrome; ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(a); mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "Web", Agent = a }); mGR.Executor.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.Executor.SolutionApplications.Add(new ApplicationPlatform() { AppName = "Web", Platform = ePlatformType.Web, Description = "New Web application" }); }
public void WebServices_WebAPIRest() { WebServicesDriver mDriver = new WebServicesDriver(mBF); Agent wsAgent = new Agent(); AgentOperations agentOperations = new AgentOperations(wsAgent); wsAgent.AgentOperations = agentOperations; wsAgent.DriverType = Agent.eDriverType.WebServices; ((AgentOperations)wsAgent.AgentOperations).Driver = mDriver; ApplicationAgent mAG = new ApplicationAgent(); mAG.Agent = wsAgent; mGR = new GingerRunner(); mGR.Executor = new GingerExecutionEngine(mGR); ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(wsAgent); mGR.Executor.BusinessFlows.Add(mBF); Activity Activity2 = new Activity(); Activity2.Active = true; Activity2.ActivityName = "Web API REST"; Activity2.CurrentAgent = wsAgent; mBF.Activities.Add(Activity2); ActWebAPIRest restAct = new ActWebAPIRest(); restAct.AddOrUpdateInputParamValue(ActWebAPIBase.Fields.EndPointURL, "https://jsonplaceholder.typicode.com/posts/1"); restAct.AddOrUpdateInputParamValue(ActWebAPIBase.Fields.CertificateTypeRadioButton, ApplicationAPIUtils.eCretificateType.AllSSL.ToString()); restAct.AddOrUpdateInputParamValue(ActWebAPIRest.Fields.RequestType, ApplicationAPIUtils.eRequestType.GET.ToString()); restAct.AddOrUpdateInputParamValue(ActWebAPIRest.Fields.ContentType, ApplicationAPIUtils.eContentType.JSon.ToString()); restAct.AddOrUpdateInputParamValue(ActWebAPIRest.Fields.ResponseContentType, ApplicationAPIUtils.eContentType.JSon.ToString()); restAct.Active = true; restAct.EnableRetryMechanism = false; restAct.ItemName = "Web API REST"; mBF.Activities[0].Acts.Add(restAct); mDriver.StartDriver(); mGR.Executor.RunRunner(); if (restAct.ReturnValues.Count > 0) { foreach (ActReturnValue val in restAct.ReturnValues) { if (val.Actual.ToString() == "OK") { Assert.AreEqual(val.Actual, "OK"); } } } }
private static void DriverWindowUtils_DriverWindowEvent(DriverWindowEventArgs args) { switch (args.EventType) { case DriverWindowEventArgs.eEventType.ShowDriverWindow: Thread staThread = new Thread(new ThreadStart(() => { if (args.Driver is IDriverWindow) //TODO: think if better to do it with reflection using DriverWindowPath { try { DriverBase driver = args.Driver; AgentOperations agentOperations = (AgentOperations)args.DataObject; string classname = "Ginger.Drivers.DriversWindows." + ((IDriverWindow)driver).GetDriverWindowName(agentOperations.Agent.DriverType); Type t = Assembly.GetExecutingAssembly().GetType(classname); if (t == null) { throw new Exception(string.Format("The Driver Window was not found '{0}'", classname)); } Window window = (Window)Activator.CreateInstance(t, driver, agentOperations.Agent); if (window != null) { mOpenWindowsDic.Add(args.Driver, window); window.Show(); System.Windows.Threading.Dispatcher.Run(); } } catch (Exception ex) { Reporter.ToUser(eUserMsgKey.StaticErrorMessage, string.Format("Error occurred while loading/showing Agent windows, error: '{0}'", ex.Message)); Reporter.ToLog(eLogLevel.ERROR, "Error occurred while loading/showing Agent windows", ex); } } })); staThread.SetApartmentState(ApartmentState.STA); staThread.IsBackground = true; staThread.Start(); break; case DriverWindowEventArgs.eEventType.CloseDriverWindow: if (mOpenWindowsDic.ContainsKey(args.Driver)) { try { //mOpenWindowsDic[args.Driver].Close(); mOpenWindowsDic.Remove(args.Driver); } catch (Exception ex) { Reporter.ToLog(eLogLevel.WARN, "Exception while trying to close Driver Window", ex); } } break; } }
void AddFirstAgentForSolutionForApplicationPlatfrom(ApplicationPlatform MainApplicationPlatform) { Agent agent = new Agent(); AgentOperations agentOperations = new AgentOperations(agent); agent.AgentOperations = agentOperations; agent.Name = MainApplicationPlatform.AppName + " - Agent 1"; switch (MainApplicationPlatform.Platform) { case ePlatformType.ASCF: agent.DriverType = Agent.eDriverType.ASCF; break; case ePlatformType.DOS: agent.DriverType = Agent.eDriverType.DOSConsole; break; case ePlatformType.Mobile: agent.DriverType = Agent.eDriverType.Appium; break; case ePlatformType.PowerBuilder: agent.DriverType = Agent.eDriverType.PowerBuilder; break; case ePlatformType.Unix: agent.DriverType = Agent.eDriverType.UnixShell; break; case ePlatformType.Web: agent.DriverType = Agent.eDriverType.SeleniumChrome; break; case ePlatformType.WebServices: agent.DriverType = Agent.eDriverType.WebServices; break; case ePlatformType.Windows: agent.DriverType = Agent.eDriverType.WindowsAutomation; break; case ePlatformType.Java: agent.DriverType = Agent.eDriverType.JavaDriver; break; default: Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "No default driver set for first agent"); break; } agent.AgentOperations.InitDriverConfigs(); WorkSpace.Instance.SolutionRepository.AddRepositoryItem(agent); }
public static void ClassInit(TestContext context) { AgentOperations agentOperations = new AgentOperations(wsAgent); wsAgent.AgentOperations = agentOperations; WorkSpace.Init(new WorkSpaceEventHandler()); WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); // Init SR SolutionRepository mSolutionRepository = WorkSpace.Instance.SolutionRepository; string TempRepositoryFolder = TestResources.GetTestTempFolder(Path.Combine("Solutions", "temp")); mSolutionRepository.Open(TempRepositoryFolder); Ginger.SolutionGeneral.Solution sol = new Ginger.SolutionGeneral.Solution(); sol.ContainingFolderFullPath = TempRepositoryFolder; WorkSpace.Instance.Solution = sol; if (WorkSpace.Instance.Solution.SolutionOperations == null) { WorkSpace.Instance.Solution.SolutionOperations = new SolutionOperations(WorkSpace.Instance.Solution); } WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder = Path.Combine(TempRepositoryFolder, "ExecutionResults"); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF WebServices Web API"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.WebServices; mDriver = new WebServicesDriver(mBF); mDriver.SaveRequestXML = true; mDriver.SavedXMLDirectoryPath = "~\\Documents"; mDriver.SecurityType = @"None"; wsAgent.DriverType = Agent.eDriverType.WebServices; ((AgentOperations)wsAgent.AgentOperations).Driver = mDriver; ApplicationAgent mAG = new ApplicationAgent(); mAG.Agent = wsAgent; mGR = new GingerRunner(); mGR.Executor = new GingerExecutionEngine(mGR); ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(wsAgent); mGR.Executor.BusinessFlows.Add(mBF); }
public AddAgentWizard(RepositoryFolder <Agent> AgentsFolder) { AgentOperations agentOperations = new AgentOperations(Agent); Agent.AgentOperations = agentOperations; this.AgentsFolder = AgentsFolder; AddPage(Name: "Introduction", Title: "Introduction", SubTitle: "Agents Introduction", Page: new WizardIntroPage("/Agents/AddAgentWizardLib/AddAgentIntro.md")); AddPage(Name: "General Details", Title: "Agent Details", SubTitle: "Set New Agent General Details", Page: new AddAgentDetailsPage()); AddPage(Name: "Driver Configurations", Title: "Driver Configurations", SubTitle: "Set New Agent Driver Configurations", Page: new AddAgentDriverConfigPage()); }
public static void ClassInit(TestContext context) { mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "Output Simulation"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.WebServices; wsAgent = new Agent(); AgentOperations agentOperations = new AgentOperations(wsAgent); wsAgent.AgentOperations = agentOperations; wsAgent.DriverType = Agent.eDriverType.WebServices; ((AgentOperations)wsAgent.AgentOperations).Driver = mDriver; ApplicationAgent mAG = new ApplicationAgent(); mAG.Agent = wsAgent; if (WorkSpace.Instance.Solution != null) { WorkSpace.Instance.Solution.LoggerConfigurations.SelectedDataRepositoryMethod = Ginger.Reports.ExecutionLoggerConfiguration.DataRepositoryMethod.TextFile; } mGR = new GingerRunner(); mGR.Executor = new GingerExecutionEngine(mGR); ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(wsAgent); mGR.Executor.BusinessFlows.Add(mBF); WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler(); WorkSpace.Init(WSEH); if (WorkSpace.Instance.Solution == null) { WorkSpace.Instance.Solution = new Solution(); } if (WorkSpace.Instance.Solution.SolutionOperations == null) { WorkSpace.Instance.Solution.SolutionOperations = new SolutionOperations(WorkSpace.Instance.Solution); } }
public void WebServices_SoapWrapperActionTest() { WebServicesDriver mDriver = new WebServicesDriver(mBF); Agent wsAgent = new Agent(); AgentOperations agentOperations = new AgentOperations(wsAgent); wsAgent.AgentOperations = agentOperations; wsAgent.DriverType = Agent.eDriverType.WebServices; ((AgentOperations)wsAgent.AgentOperations).Driver = mDriver; ApplicationAgent mAG = new ApplicationAgent(); mAG.Agent = wsAgent; mGR = new GingerRunner(); mGR.Executor = new GingerExecutionEngine(mGR); ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(wsAgent); mGR.Executor.BusinessFlows.Add(mBF); Activity Activity2 = new Activity(); Activity2.Active = true; Activity2.ActivityName = "Soap UI Wrapper action"; Activity2.CurrentAgent = wsAgent; mBF.Activities.Add(Activity2); ActSoapUI actSoapUi = new ActSoapUI(); var xmlFilePath = TestResources.GetTestResourcesFile(@"XML" + Path.DirectorySeparatorChar + "calculator_soapui_project.xml"); actSoapUi.AddNewReturnParams = true; actSoapUi.AddOrUpdateInputParamValue(ActSoapUI.Fields.ImportFile, xmlFilePath); mBF.Activities[0].Acts.Add(actSoapUi); Assert.AreEqual(1, actSoapUi.ActInputValues.Count); Assert.AreEqual(xmlFilePath, actSoapUi.ActInputValues[0].Value.ToString()); }
private void CloseStartedAgents() { if (OptionalAgentsList != null) { foreach (Agent agent in OptionalAgentsList) { if (agent.AgentOperations == null) { AgentOperations agentOperations = new AgentOperations(agent); agent.AgentOperations = agentOperations; } if (agent != null && ((AgentOperations)agent.AgentOperations).Status == Agent.eStatus.Running && agent.Tag != null && agent.Tag.ToString() == "Started with Agent Control" && !((AgentOperations)agent.AgentOperations).Driver.IsDriverBusy) { if (Reporter.ToUser(eUserMsgKey.AskIfToCloseAgent, agent.Name) == eUserMsgSelection.Yes) { agent.AgentOperations.Close(); } } } } }
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(); AgentOperations agentOperations = new AgentOperations(agent); agent.AgentOperations = agentOperations; ((AgentOperations)agent.AgentOperations).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.Executor = new GingerExecutionEngine(mGR); mGR.Executor.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.Executor.CurrentBusinessFlow = mBF; ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "JavaTestApp"; AA.Agent = agent; mGR.ApplicationAgents.Add(AA); mGR.Executor.SetCurrentActivityAgent(); }