Exemplo n.º 1
0
        public void Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;

            RanorexRepository repo        = new RanorexRepository();
            SpeechSynthesizer Speech      = new SpeechSynthesizer();
            fnPlayWavFile     PlayWavFile = new fnPlayWavFile();

            // System.DateTime DateTimeNow = System.DateTime.Now;
            // System.TimeSpan TimeNow = DateTimeNow.TimeOfDay;

            // Play error sound
            Global.WavFilePath = "Error.wav";
            PlayWavFile.Run();

            // Write out failure to error .csv file	(Global.TempString contains text to be written)
            string TextToPrint = Global.RegisterName + "," +
                                 System.DateTime.Now.ToString() + "," +
                                 Global.CurrentIteration + "," +
                                 "Scenario: " + Global.CurrentScenario + "," +
                                 Global.TempErrorString;

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(Global.ErrorFileName, Global.OpenFileForAppend))
            { file.WriteLine(TextToPrint); }

            Global.ErrorsToday++;               // PAL Status Monitor

            if (Global.SwitchQuitRunningOnError)
            {
                if (Global.DoRegisterSoundAlerts)
                {
                    Speech.Speak("An error has occurred, aborting the run");
                }
                Environment.Exit(0);
            }
        }
Exemplo n.º 2
0
        public void Run(string TempText)
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;

            RanorexRepository repo           = new RanorexRepository();
            fnWriteToLogFile  WriteToLogFile = new fnWriteToLogFile();
            fnPlayWavFile     PlayWavFile    = new fnPlayWavFile();

            Global.LogFileIndentLevel++;
            Global.LogText = "IN fnParseSwitches";
            WriteToLogFile.Run();

            if (TempText.Contains("/"))
            {                   // Process switches
                if (TempText.Contains("N") | TempText.Contains("L"))
                {               // if any of these are given then reset all and only use ones listed
                    Global.SwitchPhoneNumbersNonLoyalty = false;
                    Global.SwitchPhoneNumbersLoyalty    = false;
                }
                if (TempText.Contains("P"))
                {
                    Global.SwitchPauseBetweenScenariosOff = true;
                }
                if (TempText.Contains("N"))
                {
                    Global.SwitchPhoneNumbersNonLoyalty = true;
                }
                if (TempText.Contains("L"))
                {
                    Global.SwitchPhoneNumbersLoyalty = true;
                }
                if (TempText.Contains("A"))
                {
                    Global.SwitchAllRegistersUseAllPhoneNumbers = true;
                }
                if (TempText.Contains("S"))
                {
                    Global.SwitchScenario9Use40SKUs = true;
                }
                if (TempText.Contains("M"))
                {
                    Global.SwitchMetricOverRide = true;
                }
                if (TempText.Contains("Q"))
                {
                    Global.SwitchQuitRunningOnError = true;
                }
                if (TempText.Contains("U"))
                {
                    Global.SwitchUploadOnly = true; Global.IsPerformanceTest = true;
                }
                if (TempText.Contains("X"))
                {
                    Global.SwitchSkipCustomerLookup = true;
                    if (Global.DoScenarioFlag[17] || Global.DoScenarioFlag[20] ||
                        Global.DoScenarioFlag[21] || Global.DoScenarioFlag[22] || Global.DoScenarioFlag[23] || Global.DoScenarioFlag[25])
                    {
                        Global.WavFilePath = "SlashXSwitchSelections.wav";
                        PlayWavFile.Run();
                    }
                    Global.DoScenarioFlag[17] = false;                          // the /X switch cannot override phone looku
                    Global.DoScenarioFlag[20] = false;
                    Global.DoScenarioFlag[21] = false;
                    Global.DoScenarioFlag[22] = false;
                    Global.DoScenarioFlag[23] = false;
                    Global.DoScenarioFlag[25] = false;
                }
            }
            else if (TempText.Contains("-"))
            {                   // Process a range like 3-5
                string[] RangeItems = TempText.Split('-');

                for (int RangeOff = Convert.ToInt32(RangeItems[0]); RangeOff <= Convert.ToInt32(RangeItems[1]); RangeOff++)
                {
                    Global.DoScenarioFlag[RangeOff] = true;
                }
            }
            else
            {                   // Process single item
                if (TempText != "")
                {
                    Global.DoScenarioFlag[Convert.ToInt32(TempText)] = true;
                }
            }

            Global.LogText = "OUT fnParseSwitches";
            WriteToLogFile.Run();
            Global.LogFileIndentLevel--;
        }
Exemplo n.º 3
0
        public void Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;

            RanorexRepository repo = new RanorexRepository();

            fnPlayWavFile    PlayWavFile    = new fnPlayWavFile();
            fnWriteToLogFile WriteToLogFile = new fnWriteToLogFile();

            System.Media.SoundPlayer PlaySound = new System.Media.SoundPlayer();
            Random random = new Random();

            //*****************Start  Scenario 3 - halloween sounds ******************
            Global.CurrentScenario = 3;
            if (!Global.DoScenarioFlag[Global.CurrentScenario])
            {
                return;
            }

            int NumberOfWavFiles = 0;

            string[] WavFileNames = new string[50];
            string   WavSetStr, Prompt, DelayStrA, DelayStrB;
            int      DelayA, DelayB;


            // Read in names of .wav files
            using (System.IO.StreamReader HalloweenSoundsFile = new System.IO.StreamReader(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\HalloweenSounds.csv"))
            {
                int    Offset    = 1;
                string InputLine = "";

                for (Offset = 0; InputLine != null; Offset++)
                {
                    InputLine = HalloweenSoundsFile.ReadLine();
                    if (InputLine != null)
                    {
                        WavFileNames[Offset] = InputLine;
                        NumberOfWavFiles++;
                    }
                }
                HalloweenSoundsFile.Close();
            }

            Prompt = "Enter Set number 1 to 6 to use\n" +
                     "    Set 1: Haunted sounds\n" +
                     "    Set 2: Heartbeat\n" +
                     "    Set 3: Storms\n" +
                     "    Set 4: Bubles\n" +
                     "    Set 5: Sceams & Howling\n" +
                     "    Set 6: Door & Moaning";
            InputBoxResult BoxInput = InputBox.Show(Prompt, "Wav set to play", "");

            if (BoxInput.ReturnCode == DialogResult.Cancel)
            {
                Environment.Exit(0);
            }                                                                                   // Exit if cancel pressed
            WavSetStr = BoxInput.Text.ToUpper();

            Prompt = "Enter A for Thread.Sleep(random.Next(A,B)) if format A,B";
            InputBoxResult BoxInput2 = InputBox.Show(Prompt, "Random Play String", "");

            if (BoxInput2.ReturnCode == DialogResult.Cancel)
            {
                Environment.Exit(0);
            }                                                                                           // Exit if cancel pressed
            DelayStrA = BoxInput2.Text.ToUpper();
            DelayA    = Convert.ToInt32(DelayStrA);

            Prompt = "Enter B for Thread.Sleep(random.Next(A,B)) if format A,B";
            InputBoxResult BoxInput3 = InputBox.Show(Prompt, "Random Play String", "");

            if (BoxInput3.ReturnCode == DialogResult.Cancel)
            {
                Environment.Exit(0);
            }                                                                                           // Exit if cancel pressed
            DelayStrB = BoxInput3.Text.ToUpper();
            DelayB    = Convert.ToInt32(DelayStrB);

            while (1 != 2)
            {
                // Process the list of files found in the directory.
                string    sourceDir   = Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\HalloweenSounds\" + "Set" + WavSetStr;
                string [] fileEntries = Directory.GetFiles(sourceDir);
                foreach (string fileName in fileEntries)
                {
                    Console.WriteLine(fileName);
                    PlaySound.SoundLocation = fileName;
                    PlaySound.PlaySync();
                    Thread.Sleep(random.Next(DelayA, DelayB));
                }
            }



            // ***********End Scenario 3*****************
        }
Exemplo n.º 4
0
        public static int Main(string[] args)
        {
            // Uncomment the following 2 lines if you want to automate Windows apps
            // by starting the test executable directly
            //if (Util.IsRestartRequiredForWinAppAccess)
            //    return Util.RestartWithUiAccess();

            fnPlayWavFile      PlayWavFile      = new fnPlayWavFile();
            fnWriteToLogFile   WriteToLogFile   = new fnWriteToLogFile();
            fnWriteToErrorFile WriteToErrorFile = new fnWriteToErrorFile();
            SpeechSynthesizer  Speech           = new SpeechSynthesizer();

            Keyboard.AbortKey = System.Windows.Forms.Keys.Escape;
            int error = 0;

            // To autorun Scripts in directory <C: on reg1, D: on reg 2-n>/PAL/RanorexStudio Projects\Ranorex Automation\Alpha\bin\Debug
            //	NOTE: autorun is assumed to be type Baseline
            //      RanorexAutomation.exe auto [<iteratins-time> [<Scenario-list>] ]
            //			<iteratins-time> = number iterations
            //			<iteratins-time> = time to stop "6:00 am"
            //			<iteratins-time> = time to start and stop "6:00 am to 3:00 PM"
            //			<Scenario-list> =  list if scenarios to run comma delited "3,4,6-20"
            //		If neither <iteratins-time> or <Scenario-list> supplied will run using same paramaters as last run
            //		Just auto <iterations-time> can be given, will ust last run scenario list

            // Get command line argumets
            Global.CommandLineArg0 = "";
            Global.CommandLineArg1 = "";
            Global.CommandLineArg2 = "";
            Global.CommandLineArg3 = "";
            string[] RanorexCmdLine = Environment.GetCommandLineArgs();
            int      Arguments      = args.Length;

            switch (Arguments)
            {
            case 1:
                Global.CommandLineArg0 = RanorexCmdLine[0].ToUpper();
                Global.CommandLineArg1 = RanorexCmdLine[1].ToUpper();
                break;

            case 2:
                Global.CommandLineArg0 = RanorexCmdLine[0].ToUpper();
                Global.CommandLineArg1 = RanorexCmdLine[1].ToUpper();
                Global.CommandLineArg2 = RanorexCmdLine[2].ToUpper();
                break;

            case 3:
                Global.CommandLineArg0 = RanorexCmdLine[0].ToUpper();
                Global.CommandLineArg1 = RanorexCmdLine[1].ToUpper();
                Global.CommandLineArg2 = RanorexCmdLine[2].ToUpper();
                Global.CommandLineArg3 = RanorexCmdLine[3].ToUpper();
                break;
            }

            // For debugging auto run
//			Global.CommandLineArg1 = "AUTO";
//			Global.CommandLineArg2 = "1";
//			Global.CommandLineArg3 = "3";

//			Report.Log(ReportLevel.Info, "CommandLineStuff",
//			           "\n" + "Arglen: " + Arguments + "\n" +
//			           "Zero: " + Global.CommandLineArg0 + "\n" +
//			           "One: " + Global.CommandLineArg1 + "\n" +
//			           "Two: " + Global.CommandLineArg2 + "\n" +
//			           "Three: " + Global.CommandLineArg3 + "\n"
//			           , new RecordItemIndex(0));
//			Thread.Sleep(10000);
//			Environment.Exit(0);

            // Onetime delay for Ranorex to setup instrumentation
            Thread.Sleep(5000);

            if (Global.CommandLineArg1 == "AUTO")
            {
                Global.AutoRun = true;
            }

            try
            {
                error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occurred: " + e.ToString());
                error = -1;

                Global.LogText = "Unexpected exception occurred: " + e.ToString();
                WriteToLogFile.Run();
                Global.TempErrorString = Global.LogText;
                WriteToErrorFile.Run();
                Global.WavFilePath = "UnexpectedException.wav";
                PlayWavFile.Run();
                if (Global.DoRegisterSoundAlerts)
                {
                    Speech.Speak("Register " + Global.RegisterNumber);
                }
            }

            fnTearDown Teardown = new fnTearDown();

            Report.Log(ReportLevel.Info, "Main", "Starting Teardown", new RecordItemIndex(0));
            TestModuleRunner.Run(Teardown);
            Report.Log(ReportLevel.Info, "Main", "Teardown Finished", new RecordItemIndex(0));

            return(error);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            if (!Global.SwitchUploadOnly)
            {
                Mouse.DefaultMoveTime        = 300;
                Keyboard.DefaultKeyPressTime = 100;
                Delay.SpeedFactor            = 1.0;

                Global.PhoneNumbertype = "";                 // all types


                // Create the needed classes
                RanorexRepository  repo             = new RanorexRepository();
                fnGetEndTime       GetEndTime       = new fnGetEndTime();
                fnGetStartTime     GetStartTime     = new fnGetStartTime();
                fnPlayWavFile      PlayWavFile      = new fnPlayWavFile();
                fnWriteToLogFile   WriteToLogFile   = new fnWriteToLogFile();
                fnDumpStats        DumpStats        = new fnDumpStats();
                fnWriteToErrorFile WriteToErrorFile = new fnWriteToErrorFile();
                SpeechSynthesizer  Speech           = new SpeechSynthesizer();

                Global.LogFileIndentLevel++;
                Global.LogText = "IN fnDoScenarios";
                WriteToLogFile.Run();

                Global.CurrentIteration = 1;

                if (Global.TimeToStartExecution != "")
                {
                    Global.LogText = "Waiting for start time - IN fnDoScenarios: " + Global.TimeToStartExecution;
                    WriteToLogFile.Run();
                    Report.Log(ReportLevel.Info, "fnDoScenarios", "Waiting for start time: " + Global.TimeToStartExecution, new RecordItemIndex(0));

                    bool TimeToStart = false;
                    while (!TimeToStart)
                    {
                        System.DateTime DateTimeNow = System.DateTime.Now;
                        int             TimeUp      = System.DateTime.Compare(DateTimeNow, Convert.ToDateTime(Global.TimeToStartExecution));
                        if (TimeUp > 0)
                        {
                            TimeToStart = true;
                        }
                    }
                }

                Global.LoopingDone = false;
                while (!Global.LoopingDone)
                {
                    try
                    {
                        DoScenarioLooping();
                    }
                    catch (Exception e)
                    {
                        string sayString = "";
                        if (e.ToString().IndexOf("Thread was being aborted.") == -1)
                        {
                            sayString = e.ToString().Substring(0, 28);
                            Global.TempErrorString = "Ranorex Crashed Message: " + e.Message;
                            WriteToErrorFile.Run();
                            Global.WavFilePath = "RanorexCrashed.wav";
                            PlayWavFile.Run();

                            if (e.ToString().Contains("MemoryException"))
                            {
                                // Write out Tasklist to file in C:\PAL\Reports String.Empty
                                string TimeStampPart = System.DateTime.Now.ToString();
                                TimeStampPart = Regex.Replace(TimeStampPart, @"[/]", "-");
                                TimeStampPart = Regex.Replace(TimeStampPart, @"[:]", "-");
                                TimeStampPart = Regex.Replace(TimeStampPart, @"[ ]", "_");
                                TimeStampPart = "(" + TimeStampPart + ")";
                                string CsvFilename = "Tasklist_(" + Global.RegisterName + ")_" + TimeStampPart;

                                var proc = new Process
                                {
                                    StartInfo = new ProcessStartInfo
                                    {
                                        FileName               = Global.Register1DriveLetter + @":\PAL\Reports\GetTaskList.bat",
                                        Arguments              = CsvFilename,
                                        UseShellExecute        = false,
                                        RedirectStandardOutput = true,
                                        CreateNoWindow         = true,
                                        WorkingDirectory       = Global.Register1DriveLetter + @":\PAL\Reports\"
                                    }
                                };

                                proc.Start();
                            }
                            ;

                            //Report.Snapshot("/form[@controlname='frmWebBrowserHost']");

                            if (Global.DoRegisterSoundAlerts)
                            {
                                Speech.Speak(sayString);
                            }
                            Global.WavFilePath = "Error.wav";
                            PlayWavFile.Run(); PlayWavFile.Run(); PlayWavFile.Run(); PlayWavFile.Run();

                            string ErrorMessage;
                            ErrorMessage   = e.ToString();
                            Global.LogText = @ErrorMessage;
                            WriteToLogFile.Run();

                            MessageBox.Show(e.ToString(), "Ranorex has crashed");

                            fnTearDown Teardown = new fnTearDown();
                            Report.Log(ReportLevel.Info, "Main", "Starting Teardown", new RecordItemIndex(0));
                            TestModuleRunner.Run(Teardown);
                            Report.Log(ReportLevel.Info, "Main", "Teardown Finished", new RecordItemIndex(0));

                            Environment.Exit(0);
                        }
                    }
                }

                Global.LogText = "OUT fnDoScenarios";
                WriteToLogFile.Run();
                Global.LogFileIndentLevel--;
            }
        }
Exemplo n.º 6
0
        // ####################################################
        private void DoScenarioLooping()
        {
            RanorexRepository        repo                   = new RanorexRepository();
            fnGetEndTime             GetEndTime             = new fnGetEndTime();
            fnGetStartTime           GetStartTime           = new fnGetStartTime();
            fnPlayWavFile            PlayWavFile            = new fnPlayWavFile();
            fnWriteToLogFile         WriteToLogFile         = new fnWriteToLogFile();
            fnDumpStats              DumpStats              = new fnDumpStats();
            fnWriteToErrorFile       WriteToErrorFile       = new fnWriteToErrorFile();
            fnUpdatePALStatusMonitor UpdatePALStatusMonitor = new fnUpdatePALStatusMonitor();

            // Backoffice
            fnDoScenario13 DoScenario13 = new fnDoScenario13();
            fnDoScenario14 DoScenario14 = new fnDoScenario14();
            fnDoScenario15 DoScenario15 = new fnDoScenario15();
            fnDoScenario18 DoScenario18 = new fnDoScenario18();
            fnDoScenario19 DoScenario19 = new fnDoScenario19();
            fnDoScenario20 DoScenario20 = new fnDoScenario20();
            fnDoScenario21 DoScenario21 = new fnDoScenario21();

            // Retech
            fnDoScenario16 DoScenario16 = new fnDoScenario16();
            fnDoScenario33 DoScenario33 = new fnDoScenario33();
            fnDoScenario34 DoScenario34 = new fnDoScenario34();
            fnDoScenario36 DoScenario36 = new fnDoScenario36();
            fnDoScenario37 DoScenario37 = new fnDoScenario37();
            fnDoScenario38 DoScenario38 = new fnDoScenario38();
            fnDoScenario41 DoScenario41 = new fnDoScenario41();
            fnDoScenario42 DoScenario42 = new fnDoScenario42();
            fnDoScenario43 DoScenario43 = new fnDoScenario43();
            fnDoScenario47 DoScenario47 = new fnDoScenario47();


            // Other
            fnDoScenario50  DoScenario50  = new fnDoScenario50();
            fnUpdateItemMDB UpdateItemMDB = new fnUpdateItemMDB();


            Global.LogText = "RUN STARTED - IN fnDoScenarios Iteration: " + Global.CurrentIteration;
            WriteToLogFile.Run();

            // Decide if limited by number of iterations or time
            if (Global.IterationsToDo != -1)
            {                   // not equal to zero is based on number of iterations
                Global.StopByTime = false;
            }
            else
            {                   // equal to -1 means drive by stop time
                Global.StopByTime = true;
            }

            Global.DoDumpStats              = false;
            Global.CurrentScenario          = 0;
            Global.RetechScenariosPerformed = 0;

            if (Global.RegisterNumber == "1")
            {
                Global.LogText = "Updating SKU quantities";
                WriteToLogFile.Run();
                Global.SQLCommand = "update sku set Qty = 999999 where Qty < 5000";
                UpdateItemMDB.Run();
            }


            // If Scenario 37 Reserve Pickup then turn flag off for all SKUs EnforceStreetDate
            if (Global.DoScenarioFlag[37] && Global.RegisterNumber == "1")
            {
                Global.LogText = "Setting all EnforceStreetDates to false";
                WriteToLogFile.Run();
                Global.SQLCommand = "update sku set EnforceStreetDate = false where EnforceStreetDate = true";
                UpdateItemMDB.Run();
                Global.LogText = "Setting all IsStreetDateOverridden to true";
                WriteToLogFile.Run();
                Global.SQLCommand = "update sku set IsStreetDateOverridden = true where IsStreetDateOverridden = false";
                UpdateItemMDB.Run();
            }



            // ########## Start the main scenario looping here ##########
            do
            {
                GetStartTime.Run();     // Get Scenario start time
                InitScenarioStart(); DoScenario13.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario14.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario15.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario16.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario18.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario19.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario20.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario21.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario33.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario34.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario36.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario37.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario38.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario41.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario42.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario43.Run(); EndScenarioCleanup();
                InitScenarioStart(); DoScenario47.Run(); EndScenarioCleanup();

                InitScenarioStart(); DoScenario50.Run(); EndScenarioCleanup();
                GetEndTime.Run();       // Get Scenario end time

                //  Dump stats for all scenarios to the stats file
                Global.CurrentScenario = 0;
                if (Global.DoDumpStats)
                {
                    DumpStats.Run();
                }

                Global.CurrentIteration++;

                // See if time to quit
                if (!Global.LoopingDone)
                {
                    if (!Global.StopByTime)
                    {
                        if (Global.CurrentIteration > Global.IterationsToDo)
                        {
                            Global.LoopingDone = true;
                        }
                    }
                    else
                    {
                        System.DateTime DateTimeNow         = System.DateTime.Now;
                        string          TimeToStopExecution = Global.TimeToStopExecution;
                        int             CommaOffset         = TimeToStopExecution.IndexOf(",");
                        if (CommaOffset != -1)
                        {
                            TimeToStopExecution = Global.TimeToStopExecution.Substring(0, CommaOffset);
                        }
                        int TimeUp = System.DateTime.Compare(DateTimeNow, Convert.ToDateTime(TimeToStopExecution));
                        if (TimeUp > 0)
                        {
                            Global.LoopingDone = true;
                        }
                    }
                }

                Global.IterationsToday++;               // PAL Status Monitor

                UpdatePALStatusMonitor.Run();

                Global.LogText = "Next Iteration";
                WriteToLogFile.Run();
            } while (!Global.LoopingDone);

            Global.WavFilePath = "Register" + Global.RegisterNumber + "Finished.wav";
            PlayWavFile.Run();

            Global.LogText = "RUN FINISHED - OUT fnDoScenarios Iteration: " + Global.CurrentIteration;
            WriteToLogFile.Run();
        }
Exemplo n.º 7
0
        public void Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;

            Ranorex.Unknown    element          = null;
            RanorexRepository  repo             = new RanorexRepository();
            fnWriteToLogFile   WriteToLogFile   = new fnWriteToLogFile();
            fnBrowserGoHome    BrowserGoHome    = new fnBrowserGoHome();
            fnWriteToErrorFile WriteToErrorFile = new fnWriteToErrorFile();
            fnPlayWavFile      PlayWavFile      = new fnPlayWavFile();
            SpeechSynthesizer  Speech           = new SpeechSynthesizer();

            Global.LogFileIndentLevel++;
            Global.LogText = "IN fnWaitForBrowserToLoad";
            WriteToLogFile.Run();

            Global.POSBrowserFlush = false;

            Thread.Sleep(5000);

            int AttemptsCounter = 0;

            while (!repo.POSBrowserV25StorePortal.HomeF6.Enabled ||
                   !repo.StorePortal.QAPOSReCommerce.Enabled ||
                   !(repo.POSBrowserV25StorePortal.ProgressBar.Value == 100))
            {
                Thread.Sleep(100);

                double aaaa = repo.POSBrowserV25StorePortal.ProgressBar.Value;

                // Check for Oops Game Over
                Report.Log(ReportLevel.Info, "WaitStatus", "Ck Oops");
                if (Host.Local.TryFindSingle(repo.RecommerceTradeLink.OopsGameOverWhatYouWereAttemptingToDoInfo.AbsolutePath.ToString(), out element))
                {
                    AttemptsCounter++;
                    GlobalOverhead.Stopwatch.Start();
                    Global.TempErrorString = "Browser Oops Game Over - pressing home and retrying";
                    if (Global.DoRegisterSoundAlerts)
                    {
                        Speech.Speak(Global.TempErrorString + " try number " + AttemptsCounter.ToString());
                    }
                    WriteToErrorFile.Run();
                    Global.LogText = Global.TempErrorString;
                    WriteToLogFile.Run();
                    Global.WavFilePath = "BrowserOopsGameOver.wav	";
                    PlayWavFile.Run();
                    BrowserGoHome.Run();
                    GlobalOverhead.Stopwatch.Stop();
                }

                // Check for browser unavailable
                Report.Log(ReportLevel.Info, "WaitStatus", "Ck browser unavailable");
                if (Host.Local.TryFindSingle(repo.StorePortal.POSBrowsingIsCurrentlyUnavailableInfo.AbsolutePath.ToString(), out element))
                {
                    AttemptsCounter++;
                    GlobalOverhead.Stopwatch.Start();
                    Global.TempErrorString = "Browser Unavailable - try go home";
                    if (Global.DoRegisterSoundAlerts)
                    {
                        Speech.Speak(Global.TempErrorString + " try number " + AttemptsCounter.ToString());
                    }
                    WriteToErrorFile.Run();
                    Global.LogText = Global.TempErrorString;
                    WriteToLogFile.Run();
                    BrowserGoHome.Run();
                    GlobalOverhead.Stopwatch.Stop();
                }

                // Check for server error
                Report.Log(ReportLevel.Info, "WaitStatus", "Ck browser server error");
                if (Host.Local.TryFindSingle(repo.RecommerceTradeLink.ServerErrorInApplicationInfo.AbsolutePath.ToString(), out element))
                {
                    AttemptsCounter++;
                    GlobalOverhead.Stopwatch.Start();
                    Global.TempErrorString = "Browser Server Error In Application - try go home";
                    if (Global.DoRegisterSoundAlerts)
                    {
                        Speech.Speak(Global.TempErrorString + " try number " + AttemptsCounter.ToString());
                    }
                    WriteToErrorFile.Run();
                    Global.LogText = Global.TempErrorString;
                    WriteToLogFile.Run();
                    BrowserGoHome.Run();
                    GlobalOverhead.Stopwatch.Stop();
                }

                Report.Log(ReportLevel.Info, "WaitStatus", "look for recommerce link");
                if (!Host.Local.TryFindSingle(repo.StorePortal.QAPOSReCommerceInfo.AbsolutePath.ToString(), out element))
                {
                    if (AttemptsCounter > Global.MaxRetries)
                    {
                        Global.LogText = "Flushing wait for browser to load";
                        WriteToLogFile.Run();
                        Global.POSBrowserFlush = true;
                    }
                    else
                    {
                    }
                }
            }

            Global.LogText = "OUT fnWaitForBrowserToLoad";
            WriteToLogFile.Run();
            Global.LogFileIndentLevel--;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            if (!Global.SwitchUploadOnly)
            {
                Mouse.DefaultMoveTime        = 300;
                Keyboard.DefaultKeyPressTime = 100;
                Delay.SpeedFactor            = 1.0;

                RanorexRepository  repo             = new RanorexRepository();
                fnParseSwitches    ParseSwitches    = new fnParseSwitches();
                fnWriteToErrorFile WriteToErrorFile = new fnWriteToErrorFile();
                fnPlayWavFile      PlayWavFile      = new fnPlayWavFile();

                // Get default scenario list
                //	- use DefaultScenarioList.txt for all but last register
                //  - use DefaultScenarioListLastRegister.txt for the last register in a store
                string ListToUse        = "";
                string DefaultScenarios = "13,16,18,19,20,33,34,36,37,41,42,43,47";
//				if( Global.RegisterNumber == "4" || ( Global.RegisterName == "USA04285-3" )
//				  )
//					ListToUse = "DefaultScenarioListLastRegister.txt";
//				else
                ListToUse = "DefaultScenarioList.txt";

                try
                {
                    // Read in the default Scenario List from Register 1 \Ranorex Automation\DefaultScenarioList.txt
                    using (System.IO.StreamReader RegisterScenarioFileGet = new System.IO.StreamReader(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + ListToUse))
                    {
                        DefaultScenarios = RegisterScenarioFileGet.ReadLine();
                        RegisterScenarioFileGet.Close();
                    }
                }
                catch
                {
                    // Write out default Scenario List to Register 1 \Ranorex Automation\DefaultScenarioList.txt
                    using (System.IO.StreamWriter RegisterScenarioFilePut = new System.IO.StreamWriter(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + ListToUse))
                    {
                        RegisterScenarioFilePut.WriteLine(DefaultScenarios);
                        RegisterScenarioFilePut.Close();
                    }
                }


                string TextInput;
                string Prompt = "Enter list of scenarios like 3,5-7,/LX\n\n" +

                                "Back Office ---------------------------------------------------\n" +
                                "Scenario 13: eMail\n" +
                                "Scenario 14: Performance Dashboard\n" +
                                "Scenario 15: Performance Dashboard Loop without exiting\n" +
                                "Scenario 18: Transaction Journal\n" +
                                "Scenario 19: Cover Art\n" +
                                "Scenario 20: HR Workday Employee List\n" +
                                "Scenario 21: WIS Web-In-Store\n\n" +

                                "RETECH --------------------------------------------------------\n" +
                                "Scenario 16: Returns\n" +
                                "Scenario 33: Simple One SKU Cash\n" +
                                "Scenario 34: Simple One SKU Credit\n" +
                                "Scenario 36: Item Search\n" +
                                "Scenario 37: Reserve Pickup\n" +
                                "Scenario 38: Suspend Resume\n" +
                                "Scenario 41: GPG\n" +
                                "Scenario 42: PRP\n" +
                                "Scenario 43: Card Balance\n" +
                                "Scenario 47: Purchase 1 SKU with 5 trades and cach back\n\n" +

                                "Other --------------------------------------------------------\n" +
                                "Scenario 50: Dashboard data init (about 20 minutes)\n\n" +

                                "Switches: put comma in front of switches 2-4,7,/NXS\n" +
                                "    N=Phone Numbers NonLoyalty\n" +
                                "    L=Phone Numbers Loyalty\n" +
                                "    A=All Registers use all Phone Numbers\n" +
                                "    X=Skip Customer Lookup (NO 4,7,17,20-23,25)\n" +
                                "    M=Metrics file create when no save them\n" +
                                "    Q=Quit running when get error\n" +
                                "    S=Scenario 9 use 40 SKUs";

                if (Global.AutoRun)
                {
                    if (Global.CommandLineArg3 != "")
                    {
                        TextInput = Global.CommandLineArg3;
                    }
                    else
                    {
                        TextInput = DefaultScenarios;
                    }
                }
                else
                {
                    InputBoxResult BoxInput = InputBox.Show(Prompt, "Scenarios", DefaultScenarios);
                    if (BoxInput.ReturnCode == DialogResult.Cancel)
                    {
                        Environment.Exit(0);
                    }                                                                                           // Exit if cancel pressed
                    TextInput = BoxInput.Text.ToUpper();
                }

                // Write out default Scenario List to Register 1 \Ranorex Automation\DefaultScenarioList.txt
                using (System.IO.StreamWriter RegisterScenarioFilePut = new System.IO.StreamWriter(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + ListToUse))
                {
                    RegisterScenarioFilePut.WriteLine(TextInput);
                    RegisterScenarioFilePut.Close();
                }


                // Remove all spaces from the input
                TextInput = TextInput.Replace(" ", System.String.Empty);

                // Set flag if just Scenario 32 is selected - it consumes card numbers - so cannot run as part of normal run
                if (TextInput == "32")
                {
                    Global.JustScenario32 = true;
                }

                // Clear the DoScenarioFlag array
                for (int Offset = 0; Offset <= Global.MaxScenarioNumber; Offset++)
                {
                    Global.DoScenarioFlag[Offset] = false;
                }

                string[] PromptItems = TextInput.Split(',');
                string   TempText;
                int      PromptItemsCount = PromptItems.Length;
                int      ParseOffset;
                for (ParseOffset = 0; ParseOffset <= PromptItemsCount - 1; ParseOffset++)
                {
                    TempText = PromptItems[ParseOffset];
                    ParseSwitches.Run(TempText);
                }

                // If you can connect to the PALDB then provide the option to upload the test.
                var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MetricsRepository"].ConnectionString);
                try
                {
                    Report.Log(ReportLevel.Info, "fnGetScenariosToRun", "Open connection to DB", new RecordItemIndex(0));
                    connection.Open();
                    connection.Close();
                    var mSystemInfo = new FnSystemInfo();
                    TestModuleRunner.Run(mSystemInfo);
                }
                catch (Exception e)
                {
                    Global.IsPerformanceTest = false;
                    Global.DBAvailable       = false;

                    string sayString = "";
                    if (e.ToString().IndexOf("Thread was being aborted.") == -1)
                    {
                        sayString = e.ToString().Substring(0, 28);
                        Global.TempErrorString = "Cannot connect to Metric DB: " + e.Message;
                        WriteToErrorFile.Run();
                        //MessageBox.Show(e.ToString(),Global.TempErrorString);
                    }
                }
            }
        }