Пример #1
0
 public static void EnsureMainWindowVisible()
 {
     Ranorex.Form frmMainWindow = Host.Local.FindSingle <Ranorex.Form>("/form[@title='SystemX']", 5000);
     frmMainWindow.Activate();
 }
Пример #2
0
        public static string RestartSystemX(bool autoLogin = true)
        {
            string response = "Det oppsto kritisk feil på den foregående test. Starte System X program";

            try
            {
                // Kill System X process
                Process systemxProcess = Process.GetProcessesByName("Systemx")[0];
                systemxProcess.Kill();
                Delay.Seconds(2);
                KillCrashProgram();
                try
                {
                    // Get the System X path and run it
                    string appName = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\SystemxPath.log");
                    Process.Start(appName);

                    // If System X is not properly terminated, this window will popup
                    try
                    {
                        Ranorex.Form frmProgFail = Host.Local.FindSingle <Ranorex.Form>("/form[@title='Bekreft']", 5000);
                        frmProgFail.PressKeys("{ESCAPE}");
                    }
                    catch (ElementNotFoundException)
                    {
                        // Do nothing
                    }

                    if (autoLogin)
                    {
                        try
                        {
                            // Get login details
                            string[] details  = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\login.log").Split(';');
                            string   username = details[0];
                            string   password = details[1];
                            try
                            {
                                Ranorex.Text txtUsername = Host.Local.FindSingle <Ranorex.Text>("/form[@controlname='FPassord']/text[@controlname='UsrName']", 2000);
                                Ranorex.Text txtPassword = Host.Local.FindSingle <Ranorex.Text>("/form[@controlname='FPassord']/text[@controlname='PWord']", 2000);
                                txtUsername.Focus();
                                txtUsername.PressKeys(username);
                                txtPassword.Focus();
                                txtPassword.PressKeys(password);
                                Ranorex.Form frmCalendar = Host.Local.FindSingle <Ranorex.Form>("/form[@controlname='fdt']", 3000);
                                frmCalendar.Activate();
                                frmCalendar.PressKeys("{ENTER}");
                                Delay.Seconds(2);
                            }
                            catch (ElementNotFoundException)
                            {
                                //Do nothing
                            }
                        }
                        catch (FileNotFoundException)
                        {
                            response = "Kan ikke logge inn automatisk. Finner ikke loggfilen som inneholder de siste innloggingsdetaljer";
                        }
                    }
                }
                catch (FileNotFoundException)
                {
                    response = "Kan ikke starte System X. Loggfilen som inneholder mangler System X stien";
                }
            }
            catch (IndexOutOfRangeException)
            {
                response = "Kan ikke avslutte System X prosess. Kan ikke finne prosessnavnet";
            }
            return(response);
        }