Exemple #1
1
 //**************************************************************************************************************************************************************
 public static void SelectListBoxItemByText(Window win, String listBoxElementAutoID, String matchText)
 {
     try
     {
         TestStack.White.UIItems.ListBoxItems.ListBox l = win.Get<TestStack.White.UIItems.ListBoxItems.ListBox>(SearchCriteria.ByAutomationId(listBoxElementAutoID));
         List<TestStack.White.UIItems.ListBoxItems.ListItem> k = l.Items;
         foreach (var item in k)
         {
             if (item.Text.Equals(matchText) || item.Text.Contains(matchText))
             {
                 item.Focus();
                 //item.SetValue(matchText);
                 item.Click();
                 Thread.Sleep(int.Parse(Execution_Speed));
             }
         }
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemple #2
0
 public DeskSelectionModel(Window window)
 {
     deskSelection = window.Get<ComboBox>(SearchCriteria.ByAutomationId(DeskSelectionIDs.DESKSELECTIONCOMBOBOX));
     makeMeImmediatlyAvailable = window.Get<CheckBox>(SearchCriteria.ByAutomationId(DeskSelectionIDs.MAKEMEIMMEDIATELYAVAILABLECHECKBOX));
     okButton = window.Get<Button>(SearchCriteria.ByAutomationId(DeskSelectionIDs.OKBUTTON));
     cancelButton = window.Get<Button>(SearchCriteria.ByAutomationId(DeskSelectionIDs.OKBUTTON));
     closeButton = window.Get<Button>(SearchCriteria.ByAutomationId(DeskSelectionIDs.CLOSEBUTTON));
 }
 public void SetUp()
 {
     application     = Application.Launch(Path.Combine(TestContext.CurrentContext.TestDirectory, "YodaSpeak.exe"));
     window          = application.GetWindow("Yoda Speak");
     txtOriginalText = window.Get <TextBox>(SearchCriteria.ByAutomationId("txtOriginalText"));
     button          = window.Get <Button>(SearchCriteria.ByAutomationId("btnTranslate"));
     txtResult       = window.Get <Label>(SearchCriteria.ByAutomationId("txtResult"));
 }
Exemple #4
0
 public LoginModel(Window loginWindow)
 {
     loginTextBox = loginWindow.Get<TextBox>(SearchCriteria.ByAutomationId(LoginWindowIDs.LOGINTEXTBOX));
     passwordField = loginWindow.Get<TextBox>(SearchCriteria.ByAutomationId(LoginWindowIDs.PASSWORDTEXTBOX));
     clientField = loginWindow.Get<TextBox>(SearchCriteria.ByAutomationId(LoginWindowIDs.CLIENDTEXTBOX));
     rememberMeCheckBox = loginWindow.Get<CheckBox>(SearchCriteria.ByClassName(LoginWindowIDs.REMEMBERMECHECKBOX));
     loginButton = loginButton = loginWindow.Get<Button>(SearchCriteria.ByAutomationId(LoginWindowIDs.LOGINBUTTON));
 }
 public void Slide(Window window)
 {
     var thumb = window.Get<Thumb>("Splitter");
     double originalX = thumb.Location.X;
     thumb.SlideHorizontally(50);
     Assert.Equal(originalX + 50, thumb.Location.X);
 }
        /// <summary>
        /// given a criteria, find a control within a window
        /// </summary>
        /// <param name="window">the containing window</param>
        /// <param name="criteria">the criteria to find the control</param>
        /// <returns>the found control. null - if not found</returns>
        public IUIItem FindControl(Window window, Dictionary<string, string> criteria)
        {
            // the "all" condition
            SearchCriteria crit = SearchCriteria.All;

            // for each criteria, AND with a new condition
            foreach (string key in criteria.Keys)
            {
                switch (key.ToLower())
                {
                    case Constants.PropertyNames.ControlType:
                        crit = crit.AndControlType(GetTypeByName(criteria[key]));
                        break;
                    case Constants.PropertyNames.AutomationId:
                        crit = crit.AndAutomationId(criteria[key]);
                        break;
                    case Constants.PropertyNames.Text:
                        crit = crit.AndByText(criteria[key]);
                        break;
                    default:
                        return null;
                };
            }

            // search for control with 'crit'
            IUIItem item = window.Get(crit, WaitTime);

            // return the found control
            return item;
        }
Exemple #7
0
 public void Slide(Window window)
 {
     var thumb = window.Get<Thumb>("Splitter");
     var originalY = thumb.Location.Y;
     thumb.SlideVertically(50);
     Assert.Equal(originalY + 50, thumb.Location.Y);
 }
Exemple #8
0
        public OperationsPage(Window window)
        {
            this.window = window;

            string[] operations = { "*", "/", "-", "+", "=" };

            operationButtons = operations.ToDictionary(o => o, o => window.Get<Button>(SearchCriteria.ByText(o)));
        }
Exemple #9
0
 internal WhiteWindowShim(Window whiteWindow)
 {
     this._white = whiteWindow;
     try
     {
         if (_white.Exists<Label>())
             _text = _white.Get<Label>().Text;
     }
     catch { }
 }
Exemple #10
0
        public ResultPage(Window window)
        {
            this.window = window;

            var edits = window.GetMultiple(SearchCriteria.ByControlType(ControlType.Edit)).Cast<TextBox>().ToArray();
            resultField = edits.First(edit => edit.Text == "0");
            resultScreen = edits.First(edit => edit != resultField);
            resultButton = window.Get<Button>(SearchCriteria.ByText("="));
            okButtonCriteria = SearchCriteria.ByText("OK");
        }
Exemple #11
0
        public NumbersPage(Window window)
        {
            var symbolToButtonNameMappings = Enumerable.Range(0, 10)
                .Select(i => i.ToString()).Concat(new [] {"." })
                .ToDictionary(i => i, i => i);
            symbolToButtonNameMappings["-"] = "+/-";

            symbolButtons = symbolToButtonNameMappings
                .ToDictionary(mapping => mapping.Key,
                    mapping => window.Get<Button>(SearchCriteria.ByText(mapping.Value)));
        }
Exemple #12
0
        //**************************************************************************************************************************************************************
        public static bool CheckElementExistsByAutomationID(Window win, String automationID)
        {
            bool exists = false;

            try
            {
                exists = win.Get(SearchCriteria.ByAutomationId(automationID)).Visible;
                Thread.Sleep(int.Parse(Execution_Speed));
                return exists;
            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Exemple #13
0
        void testWhite()
        {
            List <TestStack.White.UIItems.WindowItems.Window> list = TestStack.White.Desktop.Instance.Windows();

            TestStack.White.UIItems.WindowItems.Window win = null;
            foreach (TestStack.White.UIItems.WindowItems.Window item in list)
            {
                Match match = Regex.Match(item.Title, "Ember Bootloader and Range Test.*");
                if (match.Success)
                {
                    win = item;
                    break;
                }
            }

            TestStack.White.UIItems.WindowStripControls.ToolStrip toolstrip = win.GetToolStrip("toolStrip1");

            TestStack.White.UIItems.Button b = win.Get <TestStack.White.UIItems.Button>("UnLoad");
            bool t2 = win.HasPopup();
        }
Exemple #14
0
 //**************************************************************************************************************************************************************
 public static void SelectComboBoxItemByText(Window win, String comboBoxAutoID, String matchText)
 {
     try
     {
         TestStack.White.UIItems.ListBoxItems.ComboBox c = win.Get<TestStack.White.UIItems.ListBoxItems.ComboBox>(SearchCriteria.ByAutomationId(comboBoxAutoID));
         var k = c.Items;
         foreach (var item in k)
         {
             if (item.Text.Equals(matchText) || item.Text.Contains(matchText))
             {
                 item.Focus();
                 item.Select();
                 Thread.Sleep(int.Parse(Execution_Speed));
             }
         }
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemple #15
0
        //**************************************************************************************************************************************************************
        public static void SelectCheckBoxByName(Window win, String checkBoxName, bool state)
        {
            try
            {
                AutomationProperty p = AutomationElementIdentifiers.NameProperty;
                TestStack.White.UIItems.CheckBox c = win.Get<TestStack.White.UIItems.CheckBox>(SearchCriteria.ByNativeProperty(p, checkBoxName));
                if (state)
                {
                    c.Select();
                    Thread.Sleep(int.Parse(Execution_Speed));
                }
                else
                {
                    c.UnSelect();
                    Thread.Sleep(int.Parse(Execution_Speed));
                }

            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Exemple #16
0
        //**************************************************************************************************************************************************************
        public static void SelectCheckBox(Window win, String checkBoxAutoID, bool state)
        {
            try
            {
                TestStack.White.UIItems.CheckBox c = win.Get<TestStack.White.UIItems.CheckBox>(SearchCriteria.ByAutomationId(checkBoxAutoID));
                if(state)
                {
                    c.Select();
                    Thread.Sleep(int.Parse(Execution_Speed));
                }
                else
                {
                    c.UnSelect();
                    Thread.Sleep(int.Parse(Execution_Speed));
                }

            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
        //**************************************************************************************************************************************************************


        public static void SetTextByAutomationID(Window win, String automationID, String value)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);

            try
            {
                TestStack.White.UIItems.TextBox t = (TestStack.White.UIItems.TextBox)win.Get(SearchCriteria.ByAutomationId(automationID));
                t.SetValue(value);
                Thread.Sleep(int.Parse(Execution_Speed));
                Logger.logMessage("SetTextByAutomationID " + win + "->" + automationID + "->" + value + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
            }
            catch (Exception e)
            {
                Logger.logMessage("SetTextByAutomationID " + win + "->" + automationID + "->" + value + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
Exemple #18
0
        //**************************************************************************************************************************************************************
        public static void SelectRadioButton(Window win, String radioButtonAutoID)
        {
            try
            {
                TestStack.White.UIItems.RadioButton r = win.Get<TestStack.White.UIItems.RadioButton>(SearchCriteria.ByAutomationId(radioButtonAutoID));
                r.Select();
                Thread.Sleep(int.Parse(Execution_Speed));

            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
        //**************************************************************************************************************************************************************

        public static bool CheckElementExistsByAutomationID(Window win, String automationID)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            bool exists = false;

            try
            {
                try { exists = win.Get(SearchCriteria.ByAutomationId(automationID)).Visible; }
                catch { }
                Thread.Sleep(int.Parse(Execution_Speed));
                Logger.logMessage("CheckElementExistsByAutomationID " + win + "->" + automationID + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
                return exists;
            }
            catch (Exception e)
            {
                Logger.logMessage("CheckElementExistsByAutomationID " + win + "->" + automationID + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
 void NoDateUIItemMappingDefined(Window window)
 {
     Assert.Throws<CustomUIItemException>(()=>window.Get<MyDateUIItemWithoutMappingDefined>("DateOfBirth"));
 }
 void FindCustomItem(Window window)
 {
     var myDateUIItem = window.Get<MyDateUIItem>("DateOfBirth");
     Assert.NotEqual(null, myDateUIItem);
     myDateUIItem.EnterDate(DateTime.Today);
 }
        //**************************************************************************************************************************************************************

        public static bool CheckElementExistsByName(Window win, String name)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            bool exists = false;

            try
            {
                AutomationProperty p = AutomationElementIdentifiers.NameProperty;
                try { exists = win.Get(SearchCriteria.ByNativeProperty(p, name)).Visible; }
                catch { }
                Thread.Sleep(int.Parse(Execution_Speed));
                Logger.logMessage("CheckElementExistsByName " + win + "->" + name + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
                return exists;
            }
            catch (Exception e)
            {
                Logger.logMessage("CheckElementExistsByName " + win + "->" + name + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
        //**************************************************************************************************************************************************************

        public static void SetTextByName(Window win, String name, String value)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);

            try
            {
                AutomationProperty p = AutomationElementIdentifiers.NameProperty;
                TestStack.White.UIItems.TextBox t = (TestStack.White.UIItems.TextBox)win.Get(SearchCriteria.ByNativeProperty(p, name));
                t.SetValue(value);
                Thread.Sleep(int.Parse(Execution_Speed));
                Logger.logMessage("SetTextByName " + win + "->" + name + "->" + value + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");

            }
            catch (Exception e)
            {
                Logger.logMessage("SetTextByName " + win + "->" + name + "->" + value + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
Exemple #24
0
 public String getResultText()
 {
     TestStack.White.UIItems.Label display_edit = win.Get <TestStack.White.UIItems.Label>(TestStack.White.UIItems.Finders.SearchCriteria.ByAutomationId("150"));
     Utilities.takeScreenShot(win);
     return(display_edit.Text);
 }
Exemple #25
0
 //**************************************************************************************************************************************************************
 public static void ClickButtonByAutomationID(Window win, String automationID)
 {
     try
     {
         TestStack.White.UIItems.Button b = (TestStack.White.UIItems.Button) win.Get(SearchCriteria.ByAutomationId(automationID));
         b.Click();
         Thread.Sleep(int.Parse(Execution_Speed));
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemple #26
0
 //**************************************************************************************************************************************************************
 public static void ClickElementByAutomationID(Window win, String automationID)
 {
     try
     {
         win.Get(SearchCriteria.ByAutomationId(automationID)).Click();
         Thread.Sleep(int.Parse(Execution_Speed));
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemple #27
0
        //**************************************************************************************************************************************************************
        public static void SelectRadioButtonByName(Window win, String radioButtonName)
        {
            try
            {
                AutomationProperty p = AutomationElementIdentifiers.NameProperty;
                TestStack.White.UIItems.RadioButton r = win.Get<TestStack.White.UIItems.RadioButton>(SearchCriteria.ByNativeProperty(p, radioButtonName));
                r.Select();
                Thread.Sleep(int.Parse(Execution_Speed));

            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Exemple #28
0
 //**************************************************************************************************************************************************************
 public static void ClickElementByName(Window win, String name)
 {
     try
     {
         AutomationProperty p = AutomationElementIdentifiers.NameProperty;
         win.Get(SearchCriteria.ByNativeProperty(p, name)).Click();
         Thread.Sleep(int.Parse(Execution_Speed));
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemple #29
0
 //**************************************************************************************************************************************************************
 public static void ClickButtonByName(Window win, String name)
 {
     try
     {
         AutomationProperty p = AutomationElementIdentifiers.NameProperty;
         TestStack.White.UIItems.Button b = (TestStack.White.UIItems.Button)win.Get(SearchCriteria.ByNativeProperty(p, name));
         b.Click();
         win.WaitWhileBusy();
         Thread.Sleep(int.Parse(Execution_Speed));
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
        //**************************************************************************************************************************************************************

        public static void ClickElementByName(Window win, String name)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            string windowName = null;

            try
            {
                windowName = win.Name;
                AutomationProperty p = AutomationElementIdentifiers.NameProperty;
                win.Get(SearchCriteria.ByNativeProperty(p, name)).Click();
                win.WaitWhileBusy();
                Logger.logMessage("ClickElementByName " + windowName + "->" + name + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
                Thread.Sleep(int.Parse(Execution_Speed));
            }
            catch (Exception e)
            {
                Logger.logMessage("ClickElementByName " + windowName + "->" + name + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");

                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
 public void Find(Window window)
 {
     var thumb = window.Get<Thumb>("Splitter");
     Assert.NotEqual(null, thumb);
 }
Exemple #32
0
 //**************************************************************************************************************************************************************
 public static void SetTextByAutomationID(Window win, String automationID, String value)
 {
     try
     {
         TestStack.White.UIItems.TextBox t = (TestStack.White.UIItems.TextBox)win.Get(SearchCriteria.ByAutomationId(automationID));
         t.SetValue(value);
         Thread.Sleep(int.Parse(Execution_Speed));
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemple #33
0
        static void Main(string[] args)
        {
            //setup
            var psi = new ProcessStartInfo(CAExeFile);

            _CAApp        = Application.AttachOrLaunch(psi);
            _CAMainWindow = _CAApp.GetWindow(SearchCriteria.ByAutomationId("ClinicalAccess"), InitializeOption.NoCache);

            //prepare
            _CAMainWindow.Get(SearchCriteria.ByAutomationId("btnSelectPatient")).Click();
            Window _PatientSelectDialogWindow = _CAMainWindow.ModalWindow("Patient Select Dialog");

            var PatientsTab = _PatientSelectDialogWindow.Get(SearchCriteria.ByText("Patients"));

            PatientsTab.Click();

            var cmbFacility = _PatientSelectDialogWindow.Get <ComboBox>(SearchCriteria.ByAutomationId("cmbFacility"));

            //int tryCnt = 0;
            //string FacilitySelectedValue = null;
            //while ((tryCnt < 3) && (FacilitySelectedValue != "XTRSim"))
            //{
            //    cmbFacility.Select("XTRSim");
            //    FacilitySelectedValue = cmbFacility.SelectedItem.Text;
            //    tryCnt++;
            //}

            //make sure the selection on the Unit row works
            _PatientSelectDialogWindow = _CAMainWindow.ModalWindow("Patient Select Dialog");
            _PatientSelectDialogWindow.Get(SearchCriteria.ByText("Unit Row 0")).DoubleClick();
            var DataGridView_Table = _PatientSelectDialogWindow.Get <Table>(SearchCriteria.ByAutomationId("dgvUnits"));

            cmbFacility.Select("XTRSim");

            //to avoid timeout=5000 exception
            CoreAppXmlConfiguration.Instance.BusyTimeout = 100000;//50000
            bool     found   = false;
            TableRow testRow = null;

            //go through the units to find the testing bed
            for (int i = 0; i < DataGridView_Table.Rows.Count; i++)
            {
                string pos = i.ToString();
                _PatientSelectDialogWindow.Get(SearchCriteria.ByText("Unit Row " + pos)).DoubleClick();

                var PatientsDatagrid2 = _PatientSelectDialogWindow.Get <Table>(SearchCriteria.ByAutomationId("dgvPatients"));
                var rows = PatientsDatagrid2.Rows;

                foreach (TableRow row in rows)
                {
                    if ((string)row.Cells[0].Value == "BD002(2140)") //"Room3(2666)") ; //"CP255")
                    {
                        testRow = row;
                        found   = true;
                        break;
                    }
                }
                if (found == true)
                {
                    break;
                }
            }

            //after click the row, the "Patient Select Dialog" disappear and may generate exception
            try
            {
                testRow.Click();
            }
            catch (Exception e)
            {
                Console.WriteLine("test case BedsideData exception" + e.Message.ToString());
            }

            //_CAMainWindow.Get(SearchCriteria.ByAutomationId("btnArrhythmiaReview")).Click();
            //click Bedside
            //var bedsideView = _CAMainWindow.Get(SearchCriteria.ByAutomationId("btnBedSide"));
            //bedsideView.Click();
            var WaveformsView = _CAMainWindow.Get(SearchCriteria.ByText("Waveforms"));

            WaveformsView.Click();
            //_CAMainWindow.Get(SearchCriteria.ByAutomationId("btn12Lead")).Click();
            //_CAMainWindow.Get(SearchCriteria.ByAutomationId("btnAlarmHistory")).Click();
            Thread.Sleep(2000);

            //Test codes

            _CAMainWindow.Get(SearchCriteria.ByAutomationId("btnCompressed")).Click();
            Panel    CompressedWaveformContainer = _CAMainWindow.Get <Panel>(SearchCriteria.ByAutomationId("CompressedWaveformContainer"));
            Panel    TimePanel1    = CompressedWaveformContainer.Get <Panel>(SearchCriteria.ByAutomationId("TimeControl.0"));
            string   DateStr       = TimePanel1.Get <Label>(SearchCriteria.ByAutomationId("Label.0")).Text;
            string   TimeStampStr  = TimePanel1.Get <Label>(SearchCriteria.ByAutomationId("Label.1")).Text;
            DateTime displayedTime = Convert.ToDateTime(DateStr + " " + TimeStampStr);

            //Display most recent data < 15  ?
            Assert.IsTrue((DateTime.Now - displayedTime).TotalMinutes < 15);

            //end test codes

            _CAApp.Close();
            _CAApp.Dispose();
        }
Exemple #34
0
 //**************************************************************************************************************************************************************
 public static void SetTextByName(Window win, String name, String value)
 {
     try
     {
         AutomationProperty p = AutomationElementIdentifiers.NameProperty;
         TestStack.White.UIItems.TextBox t = (TestStack.White.UIItems.TextBox)win.Get(SearchCriteria.ByNativeProperty(p, name));
         t.SetValue(value);
         Thread.Sleep(int.Parse(Execution_Speed));
     }
     catch (Exception e)
     {
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }