Exemple #1
0
 //This method Type the value which passed to this method
 public static bool Type(TestStack.White.UIItems.WindowItems.Window window, string elementid, string value)
 {
     try
     {
         TextBox textbox = window.Get <TextBox>(SearchCriteria.ByAutomationId(elementid));
         textbox.Text = value;
         return(true);
     }
     catch (Exception)  {
         try
         {
             TextBox textbox = window.Get <TextBox>(SearchCriteria.ByText(elementid));
             textbox.Text = value;
             return(true);
         }
         catch (Exception)
         {
             try
             {
                 TextBox textbox = window.Get <TextBox>(SearchCriteria.ByClassName(elementid));
                 textbox.Text = value;
                 return(true);
             }
             catch (Exception)
             {
                 Console.WriteLine("Not able to find the element");
                 return(false);
             }
         }
     }
 }
Exemple #2
0
 //This method Type the value which passed to this method
 public static bool SelectRadioButton(TestStack.White.UIItems.WindowItems.Window window, string elementid)
 {
     try
     {
         Radio radio = window.Get <Radio>(SearchCriteria.ByAutomationId(elementid));
         radio.Click();
         return(true);
     }
     catch (Exception)
     {
         try
         {
             Radio radio = window.Get <Radio>(SearchCriteria.ByText(elementid));
             radio.Click();
             return(true);
         }
         catch (Exception)
         {
             try
             {
                 Radio radio = window.Get <Radio>(SearchCriteria.ByClassName(elementid));
                 radio.Click();
                 return(true);
             }
             catch (Exception)
             {
                 Console.WriteLine("Not able to find the element");
                 return(false);
             }
         }
     }
 }
Exemple #3
0
 //Read TestBox value
 public static string ReadTextBoxValue(TestStack.White.UIItems.WindowItems.Window window, string elementid)
 {
     try
     {
         TextBox textbox = window.Get <TextBox>(SearchCriteria.ByAutomationId(elementid));
         return(textbox.Text);
     }
     catch (Exception)
     {
         try
         {
             TextBox textbox = window.Get <TextBox>(SearchCriteria.ByText(elementid));
             return(textbox.Text);
         }
         catch (Exception)
         {
             try
             {
                 TextBox textbox = window.Get <TextBox>(SearchCriteria.ByClassName(elementid));
                 return(textbox.Text);
             }
             catch (Exception)
             {
                 Console.WriteLine("Not able to get the text value");
                 return(null);
             }
         }
     }
 }
Exemple #4
0
 public bool SelectFirstSearchRecord()
 {
     try
     {
         System.Threading.Thread.Sleep(3000);
         TestStack.White.UIItems.ListBoxItems.ListItem listView = searchwindow.Get <TestStack.White.UIItems.ListBoxItems.ListItem>(SearchCriteria.ByText("Theranos.PSC.UI.PatientViewModel"));
         listView.Select();
         Thread.Sleep(3000);
         standard.Next();
         return(true);
     }
     catch (Exception)
     {
         Console.WriteLine("Not able to Find any record");
         return(true);
     }
 }
Exemple #5
0
 //This method select perticular button on the page
 public static bool Click(pscWindow window, string elementid)
 {
     try
     {
         Console.WriteLine("Trying to access the element using automation id");
         try
         {
             Button button = window.Get <Button>(SearchCriteria.ByAutomationId(elementid));
             button.Click();
             return(true);
         }
         catch (Exception)
         {
             try
             {
                 Console.WriteLine("Trying to access the element using Name of element");
                 Button button = window.Get <Button>(SearchCriteria.ByText(elementid));
                 button.Click();
                 return(true);
             }
             catch (Exception)
             {
                 try
                 {
                     Console.WriteLine("Trying to access the element using ClassName id");
                     Button button = window.Get <Button>(SearchCriteria.ByClassName(elementid));
                     button.Click();
                     return(true);
                 }
                 catch (Exception)
                 { Console.WriteLine("Not able to find out the element id");
                   return(false); }
             }
         }
     }
     catch (Exception)
     { Console.WriteLine("Not able to click on button");
       return(false); }
 }
        private void HandlePenetrationCorrectionOptions(wi.WindowItems.Window win, PenetrationCorrectionOptions op = PenetrationCorrectionOptions.None)
        {
            const string title = "Penetration Correction Options";

            if (win.Title != title)
            {
                throw new ArgumentException("Window title is not " + title);
            }
            if (op != PenetrationCorrectionOptions.None)
            {
                win.Get <wi.ListBoxItems.ListBox>(wi.Finders.SearchCriteria.ByControlType(ControlType.List)).Select((int)op);
            }
        }
Exemple #7
0
        public void TestUIBasic()
        {
            // Test d'interfície gràfica
            string rutaAlExecutable = System.AppDomain.CurrentDomain.BaseDirectory;

            rutaAlExecutable += "\\RRHHApp.exe";
            Application app = Application.Launch(rutaAlExecutable);

            TestStack.White.UIItems.WindowItems.Window w = app.GetWindows()[0];
            //------------------------------------------
            ComboBox cboOperacio = w.Get <ComboBox>("cboOperacio");
            Button   b           = w.Get <Button>("btnOperar");
            TextBox  tr          = w.Get <TextBox>("txtRes");
            //------------------------------------------
            TextBox t1 = w.Get <TextBox>("txtOp1");
            TextBox t2 = w.Get <TextBox>("txtOp2");
            int     num1 = 2, num2 = 3;

            t1.Text = "" + num1;
            t2.Text = "" + num2;
            //--------------------------------------------
            // Operació "+"
            //--------------------------------------------
            cboOperacio.Select("+");
            b.Click();
            Assert.AreEqual(num1 + num2 + "", tr.Text);
            //--------------------------------------------
            //--------------------------------------------
            // Operació "-"
            //--------------------------------------------
            cboOperacio.Select("-");
            b.Click();
            Assert.AreEqual(num1 - num2 + "", tr.Text);
            //--------------------------------------------
            //--------------------------------------------
            // Operació "*"
            //--------------------------------------------
            cboOperacio.Select("*");
            b.Click();
            Assert.AreEqual(num1 * num2 + "", tr.Text);
            //--------------------------------------------
            //--------------------------------------------
            // Operació "/"
            //--------------------------------------------
            cboOperacio.Select("/");
            b.Click();
            Assert.AreEqual(num1 / num2 + "", tr.Text);
            //--------------------------------------------

            ListView dtgPersones = w.Get <ListView>("dtgPersones");

            dtgPersones.Rows[1].Cells[0].Click();
            Assert.AreEqual("Maria", dtgPersones.SelectedRows[0].Cells[1].Text);
        }
Exemple #8
0
        //private UTILS _utils = new UTILS();

        // Perry Hunter 06/10/2013
        ///<summary>Selects the specified tab in the AWG Main Window</summary>
        /// <summary>PREREQUISITE: AWG mode is selected</summary>
        ///<param name="tabName">The AutomationID (name) of the tab to select</param>
        public static void SelectMainTabControl(string tabName)
        {
            if (AwgSetupSteps.IgnoreUi)
            {
                return;
            }

            IAWG awg = AwgSetupSteps.GetAWG("1");
            //awg.DiagComment("Selecting the " + tabName + " tab control in " + awg.ModelString + " window");

            //Find the AWG application
            Application application = Application.Attach(AWGUI.ProcessName);

            Assert.IsNotNull(application);

            //Find the main window by it's AutomationID
            Window window = application.GetWindow(awg.ModelString);

            Assert.IsNotNull(window);

            //Find the requested tab by it's AutomationID (in WPF, this is name property)
            var panelMain = (Panel)window.Get(SearchCriteria.ByAutomationId("containerMain"));

            Assert.IsNotNull(panelMain);

            //Our tab isn't really a tab. It's a panel contro
            var tab = (Panel)panelMain.Get(SearchCriteria.ByAutomationId(tabName));

            Assert.IsNotNull(tab);

            //Check the IsEnabled property
            Assert.IsTrue(tab.Enabled.Equals(true), tabName + " was not enabled, could not select when requested");

            //Click it
            tab.Click();
        }
 private static void TryEnable(string driverName, MMDevice mMDevice)
 {
     try
     {
         var hwnd = 0;
         hwnd = FindWindow(null, "Sound");
         Process soundProc;
         if (hwnd == 0)
         {
             soundProc = Process.Start("control.exe", "mmsys.cpl,,1");
         }
         else
         {
             CloseWindow((IntPtr)hwnd);
             while (hwnd == 0)
             {
                 Debug.WriteLine($"Waiting to Close ...");
                 Task.Delay(1000);
                 hwnd = FindWindow(null, "Sound");
             }
             soundProc = Process.Start("control.exe", "mmsys.cpl,,1");
         }
         hwnd = 0;
         hwnd = FindWindow(null, "Sound");
         while (hwnd == 0)
         {
             Debug.WriteLine($"Waiting ...");
             Task.Delay(1000);
             hwnd = FindWindow(null, "Sound");
         }
         if (hwnd == 0)
         {
             MessageBox.Show($"Couldnt find Sound Window.");
             return;
         }
         var id = GetWindowThreadProcessId((IntPtr)hwnd, out uint i);
         TestStack.White.Application application = TestStack.White.Application.Attach((int)i);
         Debug.WriteLine($"{application.Name}");
         TestStack.White.UIItems.WindowItems.Window window = application.GetWindow("Sound");
         var exists = window.Exists(TestStack.White.UIItems.Finders.SearchCriteria.ByText(driverName));
         if (exists)
         {
             TestStack.White.UIItems.ListBoxItems.ListItem listItem = window.Get <TestStack.White.UIItems.ListBoxItems.ListItem>(TestStack.White.UIItems.Finders.SearchCriteria.ByText(driverName));
             listItem.Focus();
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.UP);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.DOWN);
             window.Keyboard.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.F10);
             window.Keyboard.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.Enter("E");
         }
         else
         {
             window.Keyboard.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.F10);
             window.Keyboard.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.Enter("S");
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.RETURN);
             TestStack.White.UIItems.ListBoxItems.ListItem listItem = window.Get <TestStack.White.UIItems.ListBoxItems.ListItem>(TestStack.White.UIItems.Finders.SearchCriteria.ByText(driverName));
             listItem.Focus();
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.UP);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.DOWN);
             window.Keyboard.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.F10);
             window.Keyboard.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.Enter("E");
         }
         if (mMDevice != null)
         {
             if (mMDevice.State == DeviceState.Active)
             {
                 Debug.WriteLine($"{ mMDevice.FriendlyName}");
                 CloseWindow((IntPtr)hwnd);
             }
             else
             {
                 MessageBox.Show("Please Enable the device ");
             }
         }
     }
     catch (Exception)
     {
     }
 }
Exemple #10
0
        //PHunter 10/24/2012
        /// <summary>
        /// Cleans up any remaining dialogs at the start and end of each scenario. Captures a screenshot if dialog is found.
        /// </summary>
        public void CleanupDialogs()
        {
            if (AwgSetupSteps.IgnoreUi)
            {
                return;
            }

            //PWH - none of this next block seems to have been used. The Rectangle Bounds call seems to be the source of the White "out of bounds" warning

            //Needed for screen captures
            Rectangle bounds  = Screen.GetBounds(Screen.GetBounds(Point.Empty));
            string    logFile = GetLogFileName();

            //Check to see if the app is still running
            Console.WriteLine("Instantiating 'application' object - looking for running AWG70K.exe process");
            Process[] application = Process.GetProcessesByName(AWGUI.ProcessName);

            if (application.Length != 0) //if the process is not exited...
            {
                //List of all the modal windows that belong to the window.
                Console.WriteLine("Listing modal windows under the AWG70K.exe process");
                List <Window> modalWindows = new List <Window>();
                bool          validWindow  = true;

                try
                {
                    modalWindows = AWGUI.currentMainWindow.ModalWindows();
                }
                catch (Exception)
                {
                    Console.WriteLine("Exception for modalWindows was thrown and ignored");
                    validWindow = false;
                }
                if (validWindow)
                {
                    //Count the number of modal windows
                    Console.WriteLine("The number of modal widows found was: " + modalWindows.Count);
                    if (modalWindows.Count > 0)
                    {
                        //Then for each modal window, try and close it
                        for (int i = 0; i <= modalWindows.Count - 1; i++)
                        {
                            //Get the title bar text of the next window in the list
                            string dialogTitlebar = modalWindows[i].Title.ToString();
                            Console.WriteLine("Handling the " + dialogTitlebar + " dialog");

                            //Switch to the handler for each defined dialog type
                            switch (dialogTitlebar)
                            {
                            //Close any AWG MESSAGE dialogs
                            case "AWG Message":
                                Window awgMessageDialog =
                                    AWGUI.currentMainWindow.ModalWindow(SearchCriteria.ByText("AWG Message"));
                                Button MsgOKButton = awgMessageDialog.Get <Button>(SearchCriteria.ByText("OK"));
                                Delay(1);
                                Assert.IsNotNull(MsgOKButton, "OK button was not found in the AWG Message dialog");
                                MsgOKButton.Click();     //Click on OK button in Error dialog
                                break;

                            //Close any UNSAVED ASSETS dialogs
                            case "Unsaved Assets":
                                Console.WriteLine("Debug");
                                Window unsavedAssetsDialog =
                                    AWGUI.currentMainWindow.ModalWindow(SearchCriteria.ByText("Unsaved Assets"));
                                Button dontSave =
                                    unsavedAssetsDialog.Get <Button>(SearchCriteria.ByText("Don't Save"));
                                Delay(1);
                                Assert.IsNotNull(dontSave,
                                                 "Don't Save button was not found in Unsaved Assets dialog");
                                dontSave.Click();
                                break;

                            //Close any UNEXPECTED ERROR dialogs
                            case "Unexpected Error":
                                //Call Function to capture the screen shot of error message
                                CaptureImage(Point.Empty, Point.Empty, bounds, logFile, "");
                                Delay(5);     // Delay to click the button after the screen capture is done
                                Window unexpectedErrorDialog =
                                    AWGUI.currentMainWindow.ModalWindow(SearchCriteria.ByText("Unexpected Error"));
                                Button okButton = unexpectedErrorDialog.Get <Button>(SearchCriteria.ByText("OK"));
                                Delay(1);
                                Assert.IsNotNull(okButton, "OK button was not found in Unexpected Error dialog");
                                okButton.Click();

                                //Kill the test run
                                Console.WriteLine(
                                    "AWG application threw an Unexpected Errror and crashed. A screen capture was made.");
                                KillMSTest();
                                break;

                            //Close any HELP dialogs
                            case "Arbitrary Waveform Generator User Help":
                                Window helpDialog =
                                    AWGUI.currentMainWindow.ModalWindow(
                                        SearchCriteria.ByText("Arbitrary Waveform Generator User Help"));
                                Button helpCloseButton =
                                    helpDialog.Get <Button>(SearchCriteria.ByAutomationId("Close"));
                                Delay(1);
                                Assert.IsNotNull(helpCloseButton, "Close button was not found in Help dialog");
                                helpCloseButton.Click();
                                break;

                            //Wait for any PROGRESS dialogs
                            case "Progress":
                                // If the progress dialog is found, it takes 5 seconds or so to clear. This is typical
                                // when the operation was a change to the AWG mode (NORM, CAL, DIAG).
                                // TODO: PWH - once the Progress dialog has been detected, it would be better to see if it is still there once you drop to the handler and then actually handle the window, rather than just waiting for it to go away.
                                Delay(6);
                                break;

                            case "Diagnostics and Calibration":
                                // Do nothing, Diag and Cal dialog is cleared with the reset at the start of a new scenario
                                break;

                            case "C:\\Windows\\system32\\cmd.exe":
                                // Do nothing, this is the test runner command window
                                break;

                            case "":
                                // Do nothing, if empty string is captured
                                break;

                            // If the dialog is still not recognized, capture a screen shot to c:\temp and put an error in the log
                            default:
                                // Call Function to capture the screen shot of error message
                                Console.WriteLine("An unknown dialog ('" + dialogTitlebar +
                                                  "')was found in Utilities.CleanUpDialogs() function while cleaning up after a scenario. A screen capture was made.");
                                CaptureImage(Point.Empty, Point.Empty, bounds, logFile, "");
                                Delay(5);     // Delay to click the button until after the screen capture is done
                                Assert.Fail("An unknown dialog ('" + dialogTitlebar +
                                            "')was found in Utilities.CleanUpDialogs() function while cleaning up after a scenario. A screen capture was made.");
                                break;
                            }
                        }
                    }
                }
            }

            else //The app is not running, capture a screen shot to c:\temp and put an error in the log
            {
                //Call Function to capture the screen shot of error message
                CaptureImage(Point.Empty, Point.Empty, bounds, logFile, "");
                Delay(5); // Delay to click the button until after the screen capture is done
                Console.WriteLine(
                    "The AWG application did not appear to be running in Utilities.CleanUpDialogs() function while cleaning up after a scenario. A screen capture was made.");

                //Kill the test run
                KillMSTest();
            }
        }
Exemple #11
0
 public static void ClickButton(this wi.WindowItems.Window win, string text)
 {
     win.Get(wi.Finders.SearchCriteria.ByText(text)).Click();
 }