Пример #1
0
        public override void SmartSwitchWindow(ActSwitchWindow actSW)
        {
            Stopwatch St = new Stopwatch();

            St.Reset();
            St.Start();

            Boolean switchDoneFlag = false;
            String  windowTitle    = actSW.LocateValueCalculated;

            while (!switchDoneFlag)
            {
                switchDoneFlag = SwitchToWindow(windowTitle);

                if (St.ElapsedMilliseconds > actSW.WaitTime * 1000)
                {
                    break;
                }
            }

            if (!switchDoneFlag)
            {
                actSW.Error += "Window with title-" + windowTitle + " not found within specified time";
            }
        }
Пример #2
0
        public void SwitchWindowAction()
        {
            ActBrowserElement actBrowser = new ActBrowserElement();

            actBrowser.ControlAction = ActBrowserElement.eControlAction.GotoURL;
            actBrowser.AddOrUpdateInputParamValue(ActBrowserElement.Fields.URLSrc, ActBrowserElement.eURLSrc.Static.ToString());
            actBrowser.GetOrCreateInputParam("Value", "https://www.google.co.in/?gws_rd=ssl");
            actBrowser.AddOrUpdateInputParamValue(ActBrowserElement.Fields.GotoURLType, ActBrowserElement.eGotoURLType.Current.ToString());

            ActSwitchWindow actSwitchWindow = new ActSwitchWindow();

            actSwitchWindow.LocateBy    = Amdocs.Ginger.Common.UIElement.eLocateBy.ByTitle;
            actSwitchWindow.LocateValue = "Google";
            actSwitchWindow.GetOrCreateInputParam(ActSwitchWindow.Fields.WaitTime, "10");

            ActBrowserElement actBrowser1 = new ActBrowserElement();

            actBrowser1.ControlAction      = ActBrowserElement.eControlAction.GetWindowTitle;
            actBrowser1.AddNewReturnParams = true;

            //Act
            mGR.RunAction(actBrowser, false);
            mGR.RunAction(actSwitchWindow, false);
            mGR.RunAction(actBrowser1, false);

            //Assert
            Assert.AreEqual(eRunStatus.Passed, actSwitchWindow.Status, "Action Status");
            Assert.AreEqual("Google", actBrowser1.ReturnValues[0].Actual);
        }
Пример #3
0
        public ActSwitchWindowEditPage(ActSwitchWindow act)
        {
            InitializeComponent();

            mAct = act;

            WaitTimeTextBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActSwitchWindow.Fields.WaitTime));
        }
Пример #4
0
        public void CreateSwitchWindowAction(string title)
        {
            ActSwitchWindow act = new ActSwitchWindow();

            act.Description = "Switch Window - " + title;
            act.LocateBy    = eLocateBy.ByTitle;
            act.LocateValue = title;
            BusinessFlow.AddAct(act, true);
        }
Пример #5
0
        private static void ActSwitchWindowTOUISwitchWindowConvertor(Activity activity)
        {
            ActSwitchWindow actSwitchWindow = new ActSwitchWindow();

            actSwitchWindow.Active      = true;
            actSwitchWindow.Description = "Switch Window";
            actSwitchWindow.LocateBy    = Amdocs.Ginger.Common.UIElement.eLocateBy.ByTitle;
            actSwitchWindow.LocateValue = "FaceBook";
            activity.Acts.Add(actSwitchWindow);

            mBF.AddActivity(activity);

            //Act
            ExecuteActionConversion(false, true, string.Empty);

            //Assert
            Assert.AreEqual(((ActUIElement)mBF.Activities[0].Acts[1]).ElementLocateBy.ToString(), actSwitchWindow.LocateBy.ToString());
            Assert.AreEqual(((ActUIElement)mBF.Activities[0].Acts[1]).ElementLocateValue.ToString(), actSwitchWindow.LocateValue.ToString());
            Assert.AreEqual(((ActUIElement)mBF.Activities[0].Acts[1]).ElementAction.ToString(), ActUIElement.eElementAction.Switch.ToString());
            Assert.AreEqual(((ActUIElement)mBF.Activities[0].Acts[1]).ElementType.ToString(), eElementType.Window.ToString());
        }
Пример #6
0
        private void GoToPage(string calculatedValue)
        {
            Act act = null;

            switch (mAppPlatform)
            {
            case ePlatformType.Web:
            case ePlatformType.Mobile:
                act = new ActGotoURL()
                {
                    LocateBy = eLocateBy.NA, Value = calculatedValue, ValueForDriver = calculatedValue, Active = true
                };
                break;

            case ePlatformType.Java:
                act = new ActSwitchWindow {
                    LocateBy = eLocateBy.ByTitle, Value = calculatedValue, ValueForDriver = calculatedValue, Active = true, WaitTime = 5
                };
                break;

            case ePlatformType.Windows:
                act = new ActSwitchWindow {
                    LocateBy = eLocateBy.ByTitle, LocateValue = calculatedValue, LocateValueCalculated = calculatedValue, Active = true, WaitTime = 5
                };
                break;
            }
            if (act != null)
            {
                ((AgentOperations)mAgent.AgentOperations).Driver.RunAction(act);

                if (act.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed && act.Error.Contains("not support"))
                {
                    Reporter.ToUser(eUserMsgKey.StaticInfoMessage, "Navigating to Native Application not supported");
                }
                else if (!string.IsNullOrEmpty(act.Error))
                {
                    Reporter.ToUser(eUserMsgKey.StaticErrorMessage, act.Error);
                }
            }
        }
Пример #7
0
        private void GoToPage(string calculatedValue)
        {
            Act act = null;

            switch (mAppPlatform)
            {
            case ePlatformType.Web:
                act = new ActGotoURL()
                {
                    LocateBy = eLocateBy.NA, Value = calculatedValue, ValueForDriver = calculatedValue, Active = true
                };
                break;

            case ePlatformType.Java:
                act = new ActSwitchWindow {
                    LocateBy = eLocateBy.ByTitle, Value = calculatedValue, ValueForDriver = calculatedValue, Active = true
                };
                break;
            }
            if (act != null)
            {
                mAgent.Driver.RunAction(act);
            }
        }
Пример #8
0
 public abstract void SmartSwitchWindow(ActSwitchWindow act);
Пример #9
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");
            }
        }