Exemple #1
0
        private void HighlightElementClicked(object sender, RoutedEventArgs e)
        {
            ApplicationAgent currentAgent = App.AutomateTabGingerRunner.ApplicationAgents.Where(z => z.AppName == App.BusinessFlow.CurrentActivity.TargetApplication).FirstOrDefault();

            if ((currentAgent == null) || !(currentAgent.Agent.Driver is IWindowExplorer) || (currentAgent.Agent.Status != Agent.eStatus.Running))
            {
                Reporter.ToUser(eUserMsgKeys.NoRelevantAgentInRunningStatus);
            }
            else
            {
                ((IWindowExplorer)currentAgent.Agent.Driver).HighLightElement((ElementInfo)xPOMElementsGrid.Grid.SelectedItem, true);
            }
        }
Exemple #2
0
        private void HighlightElementClicked(object sender, RoutedEventArgs e)
        {
            ApplicationAgent currentAgent = (ApplicationAgent)mContext.Runner.ApplicationAgents.Where(z => z.AppName == mTargetApplication).FirstOrDefault();

            if ((currentAgent == null) || !(((Agent)currentAgent.Agent).Driver is IWindowExplorer) || (((Agent)currentAgent.Agent).Status != Agent.eStatus.Running))
            {
                Reporter.ToUser(eUserMsgKey.NoRelevantAgentInRunningStatus);
            }
            else
            {
                ((IWindowExplorer)((Agent)currentAgent.Agent).Driver).HighLightElement((ElementInfo)xPOMElementsGrid.Grid.SelectedItem, true);
            }
        }
        public static void ClassInit(TestContext context)
        {
            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;

            WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder = Path.Combine(TempRepositoryFolder, "ExecutionResults");

            mBF            = new BusinessFlow();
            mBF.Activities = new ObservableList <Activity>();
            mBF.Name       = "Error Hanlder Testing";
            mBF.Active     = true;


            Platform p = new Platform();

            p.PlatformType = ePlatformType.WebServices;


            mDriver = new WebServicesDriver(mBF);
            mDriver.SaveRequestXML        = true;
            mDriver.SavedXMLDirectoryPath = "~\\Documents";
            mDriver.SecurityType          = @"None";

            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);
        }
Exemple #4
0
        private void InitilizeWindowExplorer()
        {
            ApplicationAgent applicationAgent = new ApplicationAgent();

            applicationAgent.Agent = mWizard.mAgent;
            string targetApplicationName = App.UserProfile.Solution.ApplicationPlatforms.Where(x => x.Key == mPOM.TargetApplicationKey).FirstOrDefault().AppName;

            applicationAgent.AppName = targetApplicationName;
            mWindowExplorerPage      = new WindowExplorerPage(applicationAgent, null, WindowExplorerPage.eWindowExplorerPageContext.POMWizard);
            mWindowExplorerPage.WindowControlsGridView.DataSourceList = mPOM.MappedUIElements;
            mWindowExplorerPage.HorizontalAlignment = HorizontalAlignment.Stretch;
            mWindowExplorerPage.Width   = 700;
            xWindowExlorerFrame.Content = mWindowExplorerPage;
        }
        private void XAgentNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //save last used agent on the Solution Target Applications
            ApplicationAgent ag = ApplicationAgents.Where(x => x.Agent == (Agent)((ComboBox)sender).SelectedValue).FirstOrDefault();

            if (ag != null)
            {
                ApplicationPlatform ap = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == ag.AppName).FirstOrDefault();
                if (ap != null)
                {
                    ap.LastMappedAgentName = ag.AgentName;
                }
            }
        }
        private void TestButton_Click(object sender, RoutedEventArgs e)
        {
            TestStatusTextBlock.Text = "Executing";
            //TODO: do events?
            Act act;

            //We came from ActionEditPage
            if (mAction != null)
            {
                act = (Act)((Act)(mAction)).CreateCopy();
            }
            else
            {
                act = (Act)((Act)(mActions.CurrentItem)).CreateCopy();
            }

            SetActionDetails(act);
            App.AutomateTabGingerRunner.PrepActionValueExpression(act);
            ApplicationAgent ag = (ApplicationAgent)App.AutomateTabGingerRunner.ApplicationAgents.Where(x => x.AppName == mContext.BusinessFlow.CurrentActivity.TargetApplication).FirstOrDefault();

            if (ag != null)
            {
                App.AutomateTabGingerRunner.ExecutionLogger.Configuration.ExecutionLoggerAutomationTabContext = ExecutionLoggerConfiguration.AutomationTabContext.ActionRun;
                ((Agent)ag.Agent).RunAction(act);
            }

            TestStatusTextBlock.Text = string.Empty;
            if (act.Status != null)
            {
                TestStatusTextBlock.Text += act.Status + System.Environment.NewLine;
            }
            if (string.IsNullOrEmpty(act.Error) == false)
            {
                TestStatusTextBlock.Text += act.Error + System.Environment.NewLine;
            }
            if (string.IsNullOrEmpty(act.ExInfo) == false)
            {
                TestStatusTextBlock.Text += act.ExInfo + System.Environment.NewLine;
            }

            string retval = GetAllRetVals(act);

            if (retval != null)
            {
                TestStatusTextBlock.Text += retval + System.Environment.NewLine;
            }
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        /// <summary>
        /// This method is used to check if the agent is running or not
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool CheckIfAgentIsRunning(Activity activity, GingerExecutionEngine runner, Context context, out IWindowExplorer windowExplorerDriver)
        {
            bool isRunning = false;

            windowExplorerDriver = null;
            ApplicationAgent appAgent = GetAppAgent(activity, runner, context);

            if (appAgent != null && appAgent.Agent != null && ((AgentOperations)appAgent.Agent.AgentOperations).Driver != null && ((AgentOperations)appAgent.Agent.AgentOperations).Driver.IsRunning())
            {
                if (((AgentOperations)appAgent.Agent.AgentOperations).Driver is IWindowExplorer)
                {
                    windowExplorerDriver = (IWindowExplorer)((AgentOperations)appAgent.Agent.AgentOperations).Driver;
                }
                isRunning = true;
            }
            return(isRunning);
        }
Exemple #9
0
        public static void ClassInit(TestContext context)
        {
            WorkSpace.Init(new WorkSpaceEventHandler());
            WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository();

            // Init SR
            SolutionRepository mSolutionRepository = WorkSpace.Instance.SolutionRepository;

            Ginger.App.InitClassTypesDictionary();
            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;

            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;
            wsAgent.Driver     = mDriver;
            ApplicationAgent mAG = new ApplicationAgent();

            mAG.Agent = wsAgent;

            mGR = new GingerRunner();
            mGR.SolutionAgents = new ObservableList <Agent>();
            mGR.SolutionAgents.Add(wsAgent);

            mGR.BusinessFlows.Add(mBF);
        }
Exemple #10
0
        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 XAgentNameComboBox_DropDownOpened(object sender, EventArgs e)
        {
            ApplicationAgent applicationAgent       = (ApplicationAgent)((ComboBox)sender).DataContext;
            List <IAgent>    filteredOptionalAgents = applicationAgent.PossibleAgents;

            ////remove already mapped agents
            //List<IAgent> alreadyMappedAgents = mRunner.ApplicationAgents.Where(x => x.Agent != null).Select(x => x.Agent).ToList();
            //foreach (IAgent mappedAgent in alreadyMappedAgents)
            //{
            //    if (mappedAgent != applicationAgent.Agent)
            //    {
            //        if (filteredOptionalAgents.Contains(mappedAgent))
            //        {
            //            filteredOptionalAgents.Remove(mappedAgent);
            //        }
            //    }
            //}

            ((ComboBox)sender).ItemsSource = filteredOptionalAgents;
        }
Exemple #12
0
        /// <summary>
        /// This method is used to Start the agent
        /// </summary>
        public static bool StartAgent(Activity activity, GingerExecutionEngine runner, Context context, out IWindowExplorer windowExplorerDriver)
        {
            bool isAgentStarted = false;

            windowExplorerDriver = null;
            ApplicationAgent appAgent = GetAppAgent(activity, runner, context);

            if (appAgent != null)
            {
                if (((AgentOperations)appAgent.Agent.AgentOperations).Driver == null)
                {
                    appAgent.Agent.AgentOperations.StartDriver();
                    isAgentStarted = true;
                }
                else if (!((AgentOperations)appAgent.Agent.AgentOperations).Driver.IsRunning())
                {
                    if (Reporter.ToUser(eUserMsgKey.PleaseStartAgent, eUserMsgOption.OKCancel, eUserMsgSelection.OK) == eUserMsgSelection.OK)
                    {
                        appAgent.Agent.AgentOperations.StartDriver();
                        isAgentStarted = true;
                    }
                    else
                    {
                        isAgentStarted = false;
                    }
                }
                DriverBase driver = ((AgentOperations)appAgent.Agent.AgentOperations).Driver;
                if (driver is IWindowExplorer)
                {
                    windowExplorerDriver = (IWindowExplorer)((AgentOperations)appAgent.Agent.AgentOperations).Driver;
                }
            }
            else
            {
                isAgentStarted = false;
            }
            return(isAgentStarted);
        }
Exemple #13
0
        public static void ClassInit(TestContext context)
        {
            AutoLogProxy.Init("NonUITests");
            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;
            mBF.Platforms  = new ObservableList <Platform>();
            mBF.Platforms.Add(p);


            mDriver = new WebServicesDriver(mBF);
            mDriver.SaveRequestXML        = true;
            mDriver.SavedXMLDirectoryPath = "~\\Documents";


            wsAgent.DriverType = Agent.eDriverType.WebServices;
            wsAgent.Driver     = mDriver;
            ApplicationAgent mAG = new ApplicationAgent();

            mAG.Agent = wsAgent;

            mGR = new GingerRunner();
            mGR.SolutionAgents = new ObservableList <Agent>();
            mGR.SolutionAgents.Add(wsAgent);

            mGR.BusinessFlows.Add(mBF);

            Reporter.ToLog(eLogLevel.INFO, "Creating the GingerCoreNET WorkSpace");
            WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler();

            WorkSpace.Init(WSEH);
        }
Exemple #14
0
        private void StartAppAgent(ApplicationAgent AG)
        {
            AutoLogProxy.UserOperationStart("StartAgentButton_Click");
            Reporter.ToGingerHelper(eGingerHelperMsgKey.StartAgent, null, AG.AgentName, AG.AppName);
            if (AG.Agent.Status == Agent.eStatus.Running)
            {
                AG.Agent.Close();
            }

            AG.Agent.ProjEnvironment = App.AutomateTabEnvironment;
            AG.Agent.BusinessFlow    = App.BusinessFlow;;
            AG.Agent.SolutionFolder  = App.UserProfile.Solution.Folder;
            AG.Agent.DSList          = App.LocalRepository.GetSolutionDataSources();
            AG.Agent.StartDriver();
            //For ASCF, launch explorer automatically when launching Agent
            if (AG.Agent.IsShowWindowExplorerOnStart && AG.Agent.Status == Agent.eStatus.Running)
            {
                WindowExplorerPage WEP = new WindowExplorerPage(AG);
                WEP.ShowAsWindow();
            }

            Reporter.CloseGingerHelper();
            AutoLogProxy.UserOperationEnd();
        }
Exemple #15
0
        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();
            wsAgent.DriverType = Agent.eDriverType.WebServices;
            wsAgent.Driver     = mDriver;
            ApplicationAgent mAG = new ApplicationAgent();

            mAG.Agent = wsAgent;

            mGR = new GingerRunner();
            mGR.SolutionAgents = new ObservableList <Agent>();
            mGR.SolutionAgents.Add(wsAgent);

            mGR.BusinessFlows.Add(mBF);
        }
 private void xStartCloseAgentBtn_Click(object sender, RoutedEventArgs e)
 {
     if (AllowAgentsManipulation)
     {
         ApplicationAgent AG    = (ApplicationAgent)((ucButton)sender).DataContext;
         Agent            agent = ((Agent)AG.Agent);
         if (agent.Status != Agent.eStatus.Running)
         {
             //start Agent
             Reporter.ToStatus(eStatusMsgKey.StartAgent, null, AG.AgentName, AG.AppName);
             ((Agent)AG.Agent).ProjEnvironment = mContext.Environment;
             ((Agent)AG.Agent).BusinessFlow    = mContext.BusinessFlow;
             ((Agent)AG.Agent).SolutionFolder  = WorkSpace.Instance.Solution.Folder;
             ((Agent)AG.Agent).DSList          = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <DataSourceBase>();
             ((Agent)AG.Agent).StartDriver();
             Reporter.HideStatusMessage();
         }
         else
         {
             //close Agent
             agent.Close();
         }
     }
 }
Exemple #17
0
        private void StartAppAgent(ApplicationAgent AG)
        {
            AutoLogProxy.UserOperationStart("StartAgentButton_Click");
            Reporter.ToStatus(eStatusMsgKey.StartAgent, null, AG.AgentName, AG.AppName);
            if (((Agent)AG.Agent).Status == Agent.eStatus.Running)
            {
                ((Agent)AG.Agent).Close();
            }

            ((Agent)AG.Agent).ProjEnvironment = mContext.Environment;
            ((Agent)AG.Agent).BusinessFlow    = mContext.BusinessFlow;
            ((Agent)AG.Agent).SolutionFolder  = WorkSpace.Instance.Solution.Folder;
            ((Agent)AG.Agent).DSList          = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <DataSourceBase>();
            ((Agent)AG.Agent).StartDriver();
            //For ASCF, launch explorer automatically when launching Agent
            if (((Agent)AG.Agent).IsShowWindowExplorerOnStart && ((Agent)AG.Agent).Status == Agent.eStatus.Running)
            {
                WindowExplorerPage WEP = new WindowExplorerPage(AG, mContext);
                WEP.ShowAsWindow();
            }

            Reporter.HideStatusMessage();
            AutoLogProxy.UserOperationEnd();
        }
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            ApplicationAgent a = (ApplicationAgent)mApps.CurrentItem;

            ((Agent)a.Agent).StartDriver();
        }
Exemple #19
0
        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"));
        }
        public static void CreateRealRunSetFromDynamic(RunsetExecutor runsetExecutor, AddRunset dynamicRunset)
        {
            RunSetConfig runSetConfig = new RunSetConfig();

            runSetConfig.Name            = dynamicRunset.Name;
            runSetConfig.RunWithAnalyzer = dynamicRunset.RunAnalyzer;
            runSetConfig.RunModeParallel = dynamicRunset.RunInParallel;

            // Add runners
            foreach (AddRunner addRunner in dynamicRunset.AddRunners)
            {
                GingerRunner gingerRunner = new GingerRunner();
                gingerRunner.Name = addRunner.Name;

                if (!string.IsNullOrEmpty(addRunner.RunMode))
                {
                    gingerRunner.RunOption = (GingerRunner.eRunOptions)Enum.Parse(typeof(GingerRunner.eRunOptions), addRunner.RunMode, true);
                }

                if (!string.IsNullOrEmpty(addRunner.Environment))
                {
                    gingerRunner.UseSpecificEnvironment  = true;
                    gingerRunner.SpecificEnvironmentName = addRunner.Environment;
                }

                //add Agents
                foreach (SetAgent setAgent in addRunner.SetAgents)
                {
                    ApplicationAgent appAgent = new ApplicationAgent();
                    appAgent.AppName   = setAgent.ApplicationName;
                    appAgent.AgentName = setAgent.AgentName;
                    gingerRunner.ApplicationAgents.Add(appAgent);
                }

                // Add BFs
                foreach (AddBusinessFlow addBusinessFlow in addRunner.AddBusinessFlows)
                {
                    BusinessFlowRun businessFlowRun = new BusinessFlowRun();
                    businessFlowRun.BusinessFlowName     = addBusinessFlow.Name;
                    businessFlowRun.BusinessFlowIsActive = true;

                    // set BF Variables
                    if (addBusinessFlow.InputVariables != null)
                    {
                        foreach (InputVariable inputVariabel in addBusinessFlow.InputVariables)
                        {
                            businessFlowRun.BusinessFlowCustomizedRunVariables.Add(new VariableString()
                            {
                                DiffrentFromOrigin = true, VarValChanged = true, ParentType = inputVariabel.VariableParentType, ParentName = inputVariabel.VariableParentName, Name = inputVariabel.VariableName, InitialStringValue = inputVariabel.VariableValue, Value = inputVariabel.VariableValue
                            });
                        }
                    }
                    gingerRunner.BusinessFlowsRunList.Add(businessFlowRun);
                }
                runSetConfig.GingerRunners.Add(gingerRunner);
            }

            //Add mail Report handling
            foreach (AddRunsetOperation addOperation in dynamicRunset.AddRunsetOperations)
            {
                if (addOperation is MailReport)
                {
                    MailReport dynamicMailOperation = (MailReport)addOperation;
                    RunSetActionHTMLReportSendEmail mailOperation = new RunSetActionHTMLReportSendEmail();

                    mailOperation.Name      = "Dynamic Mail Report";
                    mailOperation.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicMailOperation.Condition, true);
                    mailOperation.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicMailOperation.RunAt, true);
                    mailOperation.Active    = true;

                    mailOperation.MailFrom = dynamicMailOperation.MailFrom;
                    mailOperation.MailTo   = dynamicMailOperation.MailTo;
                    mailOperation.MailCC   = dynamicMailOperation.MailCC;

                    mailOperation.Subject  = dynamicMailOperation.Subject;
                    mailOperation.Comments = dynamicMailOperation.Comments;
                    //mailOperation.Comments = string.Format("Dynamic {0} Execution Report" + GingerDicser.GetTermResValue(eTermResKey.RunSet));

                    mailOperation.HTMLReportTemplate           = RunSetActionHTMLReportSendEmail.eHTMLReportTemplate.HTMLReport;
                    mailOperation.selectedHTMLReportTemplateID = 100;//ID to mark defualt template

                    mailOperation.Email.IsBodyHTML  = true;
                    mailOperation.Email.EmailMethod = GingerCore.GeneralLib.Email.eEmailMethod.SMTP;
                    mailOperation.Email.MailFrom    = dynamicMailOperation.MailFrom;
                    mailOperation.Email.MailTo      = dynamicMailOperation.MailTo;
                    mailOperation.Email.Subject     = dynamicMailOperation.Subject;
                    if (dynamicMailOperation.SendViaOutlook)
                    {
                        mailOperation.Email.EmailMethod = GingerCore.GeneralLib.Email.eEmailMethod.OUTLOOK;
                    }
                    else
                    {
                        if (dynamicMailOperation.SmtpDetails != null)
                        {
                            mailOperation.Email.EmailMethod  = GingerCore.GeneralLib.Email.eEmailMethod.SMTP;
                            mailOperation.Email.SMTPMailHost = dynamicMailOperation.SmtpDetails.Server;
                            mailOperation.Email.SMTPPort     = int.Parse(dynamicMailOperation.SmtpDetails.Port);
                            mailOperation.Email.EnableSSL    = bool.Parse(dynamicMailOperation.SmtpDetails.EnableSSL);
                            if (string.IsNullOrEmpty(dynamicMailOperation.SmtpDetails.User) == false)
                            {
                                mailOperation.Email.ConfigureCredential = true;
                                mailOperation.Email.SMTPUser            = dynamicMailOperation.SmtpDetails.User;
                                mailOperation.Email.SMTPPass            = dynamicMailOperation.SmtpDetails.Password;
                            }
                        }
                    }

                    if (dynamicMailOperation.IncludeAttachmentReport)
                    {
                        EmailHtmlReportAttachment reportAttachment = new EmailHtmlReportAttachment();
                        reportAttachment.AttachmentType = EmailAttachment.eAttachmentType.Report;
                        reportAttachment.ZipIt          = true;
                        mailOperation.EmailAttachments.Add(reportAttachment);
                    }

                    runSetConfig.RunSetActions.Add(mailOperation);
                }
                else if (addOperation is JsonReport)
                {
                    JsonReport dynamicJsonReport = (JsonReport)addOperation;
                    RunSetActionJSONSummary jsonReportOperation = new RunSetActionJSONSummary();

                    jsonReportOperation.Name      = "Dynamic Json Report";
                    jsonReportOperation.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicJsonReport.Condition, true);
                    jsonReportOperation.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicJsonReport.RunAt, true);
                    jsonReportOperation.Active    = true;

                    runSetConfig.RunSetActions.Add(jsonReportOperation);
                }
            }

            // Set config
            runsetExecutor.RunSetConfig = runSetConfig;
        }
Exemple #21
0
        public void SetUserAgentTest()
        {
            //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 = "DeviceEmulationUserAgent"
            });
            mBF.CurrentActivity.TargetApplication = "DeviceEmulationUserAgent";

            var mDriver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome);

            mDriver.AutoDetect        = true;
            mDriver.HttpServerTimeOut = 60;
            //Set Browser User Agent
            mDriver.BrowserUserAgent = "Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1";
            mDriver.BrowserHeight    = "960";
            mDriver.BrowserWidth     = "600";

            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 = "DeviceEmulationUserAgent";
            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

            //get user agent string
            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"));
        }
Exemple #22
0
        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");
            }
        }
        private void TestButton_Click(object sender, RoutedEventArgs e)
        {
            TestStatusTextBlock.Text = "Executing";
            //TODO: do events?
            Act act;

            //We came from ActionEditPage
            if (mAction != null)
            {
                act = (Act)((Act)(mAction)).CreateCopy();
            }
            else
            {
                act = (Act)((Act)(mActions.CurrentItem)).CreateCopy();
            }

            // Copy from the selected Locator
            ElementLocator EL = (ElementLocator)mLocators.CurrentItem;

            act.AddNewReturnParams = true;
            act.Active             = true;
            if ((mActions.CurrentItem).GetType() == typeof(ActUIElement))
            {
                ActUIElement aaa   = (ActUIElement)mActions.CurrentItem;
                ActUIElement actUI = (ActUIElement)act;
                actUI.ElementLocateBy    = EL.LocateBy;
                actUI.ElementLocateValue = EL.LocateValue;
                actUI.Value = ValueTextBox.Text;
                actUI.GetOrCreateInputParam(ActUIElement.Fields.ControlActionValue, ValueTextBox.Text);
                actUI.GetOrCreateInputParam(ActUIElement.Fields.ControlAction, aaa.GetInputParamValue(ActUIElement.Fields.ControlAction));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereColSelector, aaa.GetInputParamValue(ActUIElement.Fields.WhereColSelector));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnTitle, aaa.GetInputParamValue(ActUIElement.Fields.WhereColumnTitle));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnValue, aaa.GetInputParamValue(ActUIElement.Fields.WhereColumnValue));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereOperator, aaa.GetInputParamValue(ActUIElement.Fields.WhereOperator));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereProperty, aaa.GetInputParamValue(ActUIElement.Fields.WhereProperty));
            }
            else
            {
                act.LocateBy = EL.LocateBy;
                act.LocateValueCalculated = EL.LocateValue;
                act.Value = ValueTextBox.Text;
            }

            App.AutomateTabGingerRunner.PrepActionVE(act);
            ApplicationAgent ag = App.AutomateTabGingerRunner.ApplicationAgents.Where(x => x.AppName == App.BusinessFlow.CurrentActivity.TargetApplication).FirstOrDefault();

            if (ag != null)
            {
                App.AutomateTabGingerRunner.ExecutionLogger.Configuration.ExecutionLoggerAutomationTabContext = ExecutionLoggerConfiguration.AutomationTabContext.ActionRun;
                ag.Agent.RunAction(act);
            }

            TestStatusTextBlock.Text = string.Empty;
            if (act.Status != null)
            {
                TestStatusTextBlock.Text += act.Status + System.Environment.NewLine;
            }
            if (string.IsNullOrEmpty(act.Error) == false)
            {
                TestStatusTextBlock.Text += act.Error + System.Environment.NewLine;
            }
            if (string.IsNullOrEmpty(act.ExInfo) == false)
            {
                TestStatusTextBlock.Text += act.ExInfo + System.Environment.NewLine;
            }

            string retval = GetAllRetVals(act);

            if (retval != null)
            {
                TestStatusTextBlock.Text += retval + System.Environment.NewLine;
            }
        }
        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();
        }
Exemple #25
0
        private void CloseAgentButton_Click(object sender, RoutedEventArgs e)
        {
            ApplicationAgent AG = (ApplicationAgent)((Button)sender).DataContext;

            ((Agent)AG.Agent).Close();
        }
Exemple #26
0
        private void LoadingAgentButton_Click(object sender, RoutedEventArgs e)
        {
            ApplicationAgent AG = (ApplicationAgent)((Button)sender).DataContext;

            ((Agent)AG.Agent).Driver.cancelAgentLoading = true;
        }