private void btnAudacity_Click(object sender, EventArgs e) { if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Audacity\\Audacity.exe")) { MessageBox.Show("Audacity is not installed..."); return; } try { System.Diagnostics.ProcessStartInfo audacityProcess = new System.Diagnostics.ProcessStartInfo(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Audacity\\Audacity.exe"); appAudacity = TestStack.White.Application.AttachOrLaunch(audacityProcess); audacityWindow = appAudacity.GetWindow("Audacity", TestStack.White.Factory.InitializeOption.NoCache); audacityToolDock = (TestStack.White.UIItems.Panel)audacityWindow.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("ToolDock"))[0]; audacityTransportToolbar = (TestStack.White.UIItems.Panel)audacityToolDock.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Audacity Transport ToolBar"))[0]; AudacityButton_Record = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Record"))[0]; AudacityButton_Pause = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Pause"))[0]; AudacityButton_Play = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Play"))[0]; AudacityButton_Stop = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Stop"))[0]; AudacityButton_SkipToStart = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Skip to Start"))[0]; AudacityButton_SkipToEnd = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Skip to End"))[0]; this.TopMost = true; this.TopMost = false; this.Activate(); } catch (Exception ex) { MessageBox.Show("Window Unavailable\n" + ex.Message); } }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.currentValueTextBox = this.Window.Get<TextBox>("currentValueTextBox"); this.defaultBox = this.Window.FindRow("default").Value<TextBox>(); this.propertychangedBox = this.Window.FindRow("propertychanged").Value<TextBox>(); this.readonlyBox = this.Window.FindRow("readonly string").Value<TextBox>(); }
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"); }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.currentCultureTextBlock = this.Window.Get<Label>("currentCultureTextBlock"); this.defaultBox = this.Window.FindRow("default").Value<ComboBox>(); this.lostFocusBox = this.Window.FindRow("lostfocus").Value<ComboBox>(); this.readonlyBox = this.Window.FindRow("readonly").Value<ComboBox>(); this.editableBox = this.Window.FindRow("editable").Value<ComboBox>(); }
private static void PerformSummationOnCalculator() { //Button with Numerical value 1 TestStack.White.UIItems.Button btn1 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("1")); //Button with Numerical value 2 TestStack.White.UIItems.Button btn2 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("2")); //Button with Numerical value 3 TestStack.White.UIItems.Button btn3 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("3")); //Button with Numerical value 4 TestStack.White.UIItems.Button btn4 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("4")); //Button with Numerical value 5 TestStack.White.UIItems.Button btn5 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("5")); //Button with Numerical value 6 TestStack.White.UIItems.Button btn6 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("6")); //Button with Numerical value 7 TestStack.White.UIItems.Button btn7 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("7")); //Button with Numerical value 8 TestStack.White.UIItems.Button btn8 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("8")); //Button with Numerical value 9 TestStack.White.UIItems.Button btn9 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("9")); //Button with Numerical value 0 TestStack.White.UIItems.Button btn0 = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("0")); //Button with text as +(for sum) TestStack.White.UIItems.Button btnSum = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("Add")); //Read button to get the result TestStack.White.UIItems.Button btnResult = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("Equals")); //add two numbers 1234 and 5678 and get the result. //Type First Numbers 1234 btn1.Click(); btn2.Click(); btn3.Click(); btn4.Click(); //Press Add button btnSum.Click(); //Type 2nd number btn5.Click(); btn6.Click(); btn7.Click(); btn8.Click(); //Get the result btnResult.Click(); //read the result TestStack.White.UIItems.Label resultLable = _mainWindow.Get <TestStack.White.UIItems.Label>(SearchCriteria.ByAutomationId("150")); string result = resultLable.Text; if (result == "6912") { Console.WriteLine("Addition of numbers is correct.the result is {0}", result); } // Assert.AreEqual("6912", resultLable, "Sorry Summation is wrong!!"); }
public void OneTimeSetUp() { var title = "EnumRowWindow"; this.application = Application.AttachOrLaunch(Info.CreateStartInfo(title)); this.window = this.application.GetWindow(title); this.loseFocusButton = this.window.GetByText<Button>("lose focus"); this.currentCultureTextBlock = this.window.Get<Label>("currentTextBlock"); this.currentBox = this.window.FindRow("current").Value<ComboBox>(); this.explicitTypeBox = this.window.FindRow("explicit_type").Value<ComboBox>(); this.lostFocusBox = this.window.FindRow("lostfocus").Value<ComboBox>(); this.readonlyBox = this.window.FindRow("readonly").Value<ComboBox>(); this.editableBox = this.window.FindRow("editable").Value<ComboBox>(); }
/// <summary> /// Find difference between dates through calculator /// </summary> private static void DateDifferenceCalculation() { Keyboard.Instance.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.CONTROL); Keyboard.Instance.Enter("E"); Keyboard.Instance.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.CONTROL); //On Date window find the difference between dates. //Set value into combobox var comboBox = _mainWindow.Get <TestStack.White.UIItems.ListBoxItems.ComboBox>(SearchCriteria.ByAutomationId("4003")); comboBox.Select("Calculate the difference between two dates"); //Click on Calculate button TestStack.White.UIItems.Button caclButton = _mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByAutomationId("4009")); caclButton.Click(); }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.saveButton = this.Window.GetByText<Button>("save"); this.currentValueTextBox = this.Window.Get<TextBox>("currentValueTextBox"); this.currentMinValueTextBox = this.Window.Get<TextBox>("currentMinValueTextBox"); this.currentMaxValueTextBox = this.Window.Get<TextBox>("currentMaxValueTextBox"); this.currentNullableValueTextBox = this.Window.Get<TextBox>("currentNullableValueTextBox"); this.defaultRow = this.Window.FindRow("default"); this.propertychangedRow = this.Window.FindRow("propertychanged"); this.readonlyRow = this.Window.FindRow("readonly"); this.nullableRow = this.Window.FindRow("nullable"); this.cmRow = this.Window.FindRow("explicit cm"); }
private void click_ExternBtn(TestStack.White.UIItems.Button Button_) { try { if (Button_.Enabled) { Point cursorPos = System.Windows.Forms.Cursor.Position; Button_.Click(); System.Windows.Forms.Cursor.Position = cursorPos; this.TopMost = true; this.TopMost = false; this.Activate(); } } catch (Exception ex) { MessageBox.Show("Button Unavailable"); } }
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(); }
public void ThirdWindowTBtnSlider() { setupapp(); Window mainWindow = application.GetWindow("MainWindow"); TestStack.White.UIItems.TabItems.TabPage tabInput = mainWindow.Get <White.UIItems.TabItems.TabPage>(SearchCriteria.ByText("Other Controls")); tabInput.Click(); TestStack.White.UIItems.Hyperlink hlink = mainWindow.Get <White.UIItems.Hyperlink>(SearchCriteria.ByText("Link Text")); hlink.Click(); TestStack.White.UIItems.Button btnaddtextbox = mainWindow.Get <White.UIItems.Button>(SearchCriteria.ByText("Add TextBox")); btnaddtextbox.Click(); btnaddtextbox.Click(); btnaddtextbox.Click(); btnaddtextbox.Click(); TestStack.White.UIItems.Slider sldrOne = mainWindow.Get <White.UIItems.Slider>(SearchCriteria.ByAutomationId("Slider")); sldrOne.LargeIncrementButton.Click(); Thread.Sleep(4000); sldrOne.LargeDecrementButton.Click(); Thread.Sleep(4000); }
public void thirdwindowNode() { Window mainWindow = application.GetWindow("MainWindow"); TestStack.White.UIItems.TreeItems.TreeNode nodeOne = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Root")); nodeOne.Select(); nodeOne.Expand(); Thread.Sleep(2000); TestStack.White.UIItems.TreeItems.TreeNode nodeTwo = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Child")); nodeTwo.Select(); nodeTwo.Expand(); Thread.Sleep(2000); TestStack.White.UIItems.TreeItems.TreeNode nodeThree = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Grand Child")); nodeThree.Select(); Thread.Sleep(2000); TestStack.White.UIItems.TreeItems.TreeNode nodeFour = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Lots Of Children")); nodeFour.Select(); nodeFour.Expand(); Thread.Sleep(1000); TestStack.White.UIItems.TreeItems.TreeNode nodeFour_child1 = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Child1")); nodeFour_child1.Select(); Thread.Sleep(1000); TestStack.White.UIItems.TreeItems.TreeNode nodeFour_child2 = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Child2")); nodeFour_child2.Select(); Thread.Sleep(1000); TestStack.White.UIItems.TreeItems.TreeNode nodeFour_child3 = mainWindow.Get <White.UIItems.TreeItems.TreeNode>(SearchCriteria.ByText("Child3")); nodeFour_child3.Select(); Thread.Sleep(1000); nodeFour.Collapse(); Thread.Sleep(2000); TestStack.White.UIItems.Button btnAddNode = mainWindow.Get <White.UIItems.Button>(SearchCriteria.ByText("Add Node")); btnAddNode.Click(); btnAddNode.Click(); Thread.Sleep(2000); application.Close(); }
private void btnAudacity_Click(object sender, EventArgs e) { if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Audacity\\Audacity.exe")) { MessageBox.Show("Audacity is not installed..."); return; } try { System.Diagnostics.ProcessStartInfo audacityProcess = new System.Diagnostics.ProcessStartInfo(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Audacity\\Audacity.exe"); appAudacity = TestStack.White.Application.AttachOrLaunch(audacityProcess); audacityWindow = appAudacity.GetWindow("Audacity", TestStack.White.Factory.InitializeOption.NoCache); audacityToolDock = (TestStack.White.UIItems.Panel)audacityWindow.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("ToolDock"))[0]; audacityTransportToolbar = (TestStack.White.UIItems.Panel)audacityToolDock.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Audacity Transport ToolBar"))[0]; AudacityButton_Record = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Record"))[0]; AudacityButton_Pause = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Pause"))[0]; AudacityButton_Play = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Play"))[0]; AudacityButton_Stop = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Stop"))[0]; AudacityButton_SkipToStart = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Skip to Start"))[0]; AudacityButton_SkipToEnd = (TestStack.White.UIItems.Button)audacityTransportToolbar.GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Skip to End"))[0]; this.TopMost = true; this.TopMost = false; this.Activate(); } catch (Exception ex) { MessageBox.Show("Window Unavailable\n"+ex.Message); } }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.currentValueTextBox = this.Window.Get<TextBox>("currentValueTextBox"); }
//************************************************************************************************************************************************************** public static List<TestStack.White.UIItems.Button> GetAllTableButtonElements(TestStack.White.UIItems.TableItems.Table table, Window window) { Logger.logMessage("Function call @ :" + DateTime.Now); List<TestStack.White.UIItems.Button> elements = null; try { Logger.logMessage("GetAllTableButtonElements " + table + "->" + window); PropertyCondition tableElementsCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button); AutomationElementCollection allTableElements = table.AutomationElement.FindAll(TreeScope.Descendants, tableElementsCondition); foreach (AutomationElement item in allTableElements) { TestStack.White.UIItems.Button l = new TestStack.White.UIItems.Button(item, window.ActionListener); elements.Add(l); } Logger.logMessage("GetAllTableButtonElements " + table + "->" + window + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); return elements; } catch (Exception e) { Logger.logMessage("GetAllTableButtonElements " + table + "->" + window + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
public void Click(Button button, ButtonParam param) { button.Click(); }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); }
public void TestMethod1() { TestStack.White.Application app = base.Application; Window window = app.GetWindow(SearchCriteria.ByAutomationId("StartScreen"), InitializeOption.WithCache); Delete_LevelData(); window.WaitWhileBusy(); //click the cont button Button contBtn = window.Get <Button>(SearchCriteria.ByAutomationId("button2")); contBtn.Click(); // get cont window Window cont = app.GetWindow(SearchCriteria.ByAutomationId("ContinueGame"), InitializeOption.WithCache); cont.WaitWhileBusy(); IUIItem[] children1 = cont.GetMultiple(SearchCriteria.All); //get lvl 1 button Button lvl1Btn = (Button)children1[1]; lvl1Btn.Click(); // get game window Window game = app.GetWindow(SearchCriteria.ByAutomationId("Form1"), InitializeOption.NoCache); game.Focus(); UIItemCollection items = game.Items; items[24].Focus(); SendKeys.Send("{SPACE}"); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT);//winElem14.SendKeys(Keys.Right); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.SPACE);//winElem14.SendKeys(Keys.Space); //input.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.LEFT);//winElem14.SendKeys(Keys.Left); Window win = app.GetWindow(SearchCriteria.ByAutomationId("LevelComplete"), InitializeOption.WithCache); win.WaitWhileBusy(); children1 = win.GetMultiple(SearchCriteria.All); //35 Button saveBtn = (Button)children1[4]; saveBtn.Click(); win.WaitWhileBusy(); Button quitBtn = (Button)children1[5]; quitBtn.Click(); app.Close(); app.Dispose(); }
//************************************************************************************************************************************************************** public static void UIA_ClickButtonByName(AutomationElement uiaWindow, Window window, string name) { Logger.logMessage("Function call @ :" + DateTime.Now); try { PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button); AutomationElementCollection buttons = uiaWindow.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement e in buttons) { if (e.Current.Name.Equals(name)) { TestStack.White.UIItems.Button t = new TestStack.White.UIItems.Button(e, window.ActionListener); t.Click(); } } Thread.Sleep(int.Parse(Execution_Speed)); Logger.logMessage("UIA_ClickButtonByName " + uiaWindow + "->" + window + "->" + name + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); } catch (Exception e) { Logger.logMessage("UIA_ClickButtonByName " + uiaWindow + "->" + window + "->" + name + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }