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>(); }
//************************************************************************************************************************************************************** public static List<TestStack.White.UIItems.Label> GetAllTableTextElements(TestStack.White.UIItems.TableItems.Table table, Window window) { Logger.logMessage("Function call @ :" + DateTime.Now); List<TestStack.White.UIItems.Label> elements = null; try { Logger.logMessage("GetAllTableTextElements " + table + "->" + window); PropertyCondition tableElementsCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection allTableElements = table.AutomationElement.FindAll(TreeScope.Descendants, tableElementsCondition); foreach (AutomationElement item in allTableElements) { TestStack.White.UIItems.Label l = new TestStack.White.UIItems.Label(item, window.ActionListener); elements.Add(l); } Logger.logMessage("GetAllTableTextElements " + table + "->" + window + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); return elements; } catch (Exception e) { Logger.logMessage("GetAllTableTextElements " + table + "->" + window + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
//************************************************************************************************************************************************************** public static void ClickTextInsidePanel(Window window, TestStack.White.UIItems.Panel pane, string text) { Logger.logMessage("Function call @ :" + DateTime.Now); try { Logger.logMessage("ClickTextInsidePanel " + window + "->" + pane + "->" + text); PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection textElements = pane.AutomationElement.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement item in textElements) { if (item.Current.Name.Equals(text)) { var t = new TestStack.White.UIItems.Label(item, window.ActionListener); t.Focus(); t.Click(); Logger.logMessage("ClickTextInsidePanel " + window + "->" + pane + "->" + text + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); break; } } } catch (Exception e) { Logger.logMessage("ClickTextInsidePanel " + window + "->" + pane + "->" + text + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
//************************************************************************************************************************************************************** public static void UIA_ClickTextByAutomationID(AutomationElement uiaWindow, Window window, string automationID) { Logger.logMessage("Function call @ :" + DateTime.Now); try { PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection texts = uiaWindow.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement e in texts) { if (e.Current.AutomationId.Equals(automationID)) { TestStack.White.UIItems.Label t = new TestStack.White.UIItems.Label(e, window.ActionListener); t.Click(); } } Thread.Sleep(int.Parse(Execution_Speed)); Logger.logMessage("UIA_ClickTextByAutomationID " + uiaWindow + "->" + window + "->" + automationID + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); } catch (Exception e) { Logger.logMessage("UIA_ClickTextByAutomationID " + uiaWindow + "->" + window + "->" + automationID + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
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); }
private static void AddInfoFromDetailPane(TestCase testResult, Label label) { var id = label.AutomationElement.Current.AutomationId; switch (id) { case "detailPanelHeader": var name = NormalizePointerInfo(label.Text); testResult.Name += name; if (label.Text != label.HelpText) testResult.FullyQualifiedName += label.HelpText; break; case "hasSourceToolTip": testResult.Source += label.Text; break; case "testResultSummaryText Failed": case "testResultSummaryText Skipped": case "testResultSummaryText Passed": testResult.Result += NormalizePointerInfo(label.Text); break; case "errorMessageItem": testResult.Error += label.Text.ReplaceIgnoreCase(Path.GetDirectoryName(SolutionFile), "$(SolutionDir)"); break; case "hyperlinkText": testResult.Stacktrace = label.Text.ReplaceIgnoreCase(Path.GetDirectoryName(SolutionFile), "$(SolutionDir)"); break; case "sourceTextHeader": case "noSourceAvailableToolTip": case "elapsedTimeText": case "Stacktraceheader": case "StackFramePanel": // ignore break; default: testResult.Unexpected += $"{id}={label.Text} "; break; } }
protected override void PostSetup() { document = BrowserWindow.SilverlightDocument; label = document.Get<Label>("status"); }
public bool IsParcelCreatedSuccessfully() { AutomationElement childElementNotification = GetChildElement(NotificationMsg, new PropertyCondition(AutomationElement.AutomationIdProperty, ElementProperties.NotificationMessage)); Label parcelSuccessfulLabel = new Label(childElementNotification, new NullActionListener()); var shipmentNum = ShipmentNumber.Text.Substring(12).TrimEnd(); var seqNum = ParcelSeqNumber.Text[0]; var actualTxt = "Parcel '" + seqNum + "' for shipment '" + shipmentNum + "' created successfully."; return (parcelSuccessfulLabel.Text.Equals(actualTxt)) ? true : false; }