public void AutomationId() { // Act By configuration = By.AutomationId("SomeAutomationId"); // Assert Assert.AreEqual(1, configuration.Configuration.Count); }
public void GetColor_BlueTextBox_ReturnsBlue() { var textBox = UI.GetChild(By.AutomationId("CUI_Blue_TextBox"), From.Element(_testWindow)); var color = ColorDetector.GetColor(textBox, At.BottomRight(50, 50)); Assert.AreEqual(Color.FromArgb(255, 0, 0, 255), color); }
public void GetColor_RedTextBox_ReturnsRed() { var textBox = UI.GetChild(By.AutomationId("CUI_Red_TextBox"), From.Element(_testWindow)); var color = ColorDetector.GetColor(textBox); Assert.AreEqual(Color.FromArgb(255, 255, 0, 0), color); }
public void DoubleClick_InsideTheWindow_ExecutesTheDoubleClick() { var textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); MouseEx.DoubleClick(textBox).And.Wait(1000); Assert.AreEqual("TextBox got doubleclicked", textBox.Text); }
public void GetParent_FromAutomationIdButton_ReturnsTheRightPanel() { var button = UI.GetChild(By.AutomationId("CUI_Button", CompareKind.Contains), From.Element(_testWindow), With.NoAssert()); var parentPanel = UI.GetParent(By.ClassName("Button"), From.Element(button)); Assert.AreEqual("CUI_AutomationIdsPanel", parentPanel.AutomationId); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_WindowFocusTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); }
public void GetChild_ByClassName_ReturnsFirstResult() { var panel = UI.GetChild(By.AutomationId("CUI_ClassNamesPanel"), From.Element(_testWindow)); var foundChild = UI.GetChild <BasicButton>(By.ClassName("Button"), From.Element(panel), With.NoAssert()); Assert.IsNotNull(foundChild); Assert.AreEqual("First", foundChild.Text); }
public void GetChild_ByAutomationId_ReturnsFirstResult() { var panel = UI.GetChild(By.AutomationId("CUI_AutomationIdsPanel"), From.Element(_testWindow)); var foundChild = UI.GetChild(By.AutomationId("CUI_Button", CompareKind.Contains), From.Element(panel), With.NoAssert()); Assert.IsNotNull(foundChild); Assert.AreEqual("CUI_Button1", foundChild.AutomationId); }
public void AutomationId() { // Act By configuration = By.AutomationId("SomeAutomationId"); // Assert Assert.AreEqual(1, configuration.Configuration.Count); Assert.AreEqual(PropertyExpressionOperator.EqualTo, configuration.Configuration.First().PropertyOperator); }
public void GetChild_ByName_ReturnsFirstResult() { var panel = UI.GetChild(By.AutomationId("CUI_NamesPanel"), From.Element(_testWindow)); var foundChild = UI.GetChild(By.Name("B-", CompareKind.StartsWith), From.Element(panel), With.NoAssert()); Assert.IsNotNull(foundChild); Assert.AreEqual("B-First", foundChild.Name); }
public void SlList_DynamicObjectRecognition_Succeeds() { BrowserWindowUnderTest b = BrowserWindowUnderTest.Launch(silverlightApplicationHtmlPageUrl); b.SetFocus(); SilverlightList oList = b.Find <SilverlightList>(By.AutomationId("listBox1")); oList.SelectedIndices = new[] { 2 }; Assert.IsTrue(oList.SelectedItemsAsString == "Coded UI Test"); b.Close(); }
public void GetChildren_ByClassName_ReturnsAllThreeButtons() { var panel = UI.GetChild(By.AutomationId("CUI_ClassNamesPanel"), From.Element(_testWindow)); var foundChild = UI.GetChildren <BasicButton>(By.ClassName("Button"), From.Element(panel), With.NoAssert()).ToList(); Assert.AreEqual(3, foundChild.Count); Assert.AreEqual("First", foundChild[0].Text); Assert.AreEqual("Second", foundChild[1].Text); Assert.AreEqual("Third", foundChild[2].Text); }
public void GetChildren_ByAutomationId_ReturnsAllThreeButtons() { var panel = UI.GetChild(By.AutomationId("CUI_AutomationIdsPanel"), From.Element(_testWindow)); var foundChild = UI.GetChildren(By.AutomationId("CUI_Button", CompareKind.Contains), From.Element(panel), With.NoAssert()).ToList(); Assert.AreEqual(3, foundChild.Count); Assert.AreEqual("CUI_Button1", foundChild[0].AutomationId); Assert.AreEqual("CUI_Button2", foundChild[1].AutomationId); Assert.AreEqual("CUI_Button3", foundChild[2].AutomationId); }
public void SlTab_SelectedIndex_Succeeds() { BrowserWindowUnderTest b = BrowserWindowUnderTest.Launch(silverlightApplicationHtmlPageUrl); b.SetFocus(); SilverlightTab oTab = b.Find <SilverlightTab>(By.AutomationId("tabControl1")); oTab.SelectedIndex = 1; Assert.IsTrue(oTab.SourceControl.Items[0].Name == "tabItem1"); b.Close(); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
public void GetChild_SearchForNotExistingAndDefinedTimeot_SearchesOnlyTheTimeoutTime() { var watch = new Stopwatch(); watch.Start(); UI.GetChild(By.AutomationId("CUI_GoHomeYouAreDrunk"), From.Element(_testWindow), With.Timeout(1000).And.NoAssert()); watch.Stop(); var elapsed = watch.Elapsed; Assert.IsTrue(elapsed.TotalMilliseconds > 900 && elapsed.TotalMilliseconds < 1100, elapsed.ToString()); }
public void InvokePattern_ReadFromButton_CanInvoked() { var button = UI.GetChild(By.AutomationId("CUI_ShowMessageBox_Button"), From.Element(_mainWindow)); var pattern = Patterns.GetInvokePattern(button.AutomationElement); pattern.Invoke(); DynamicSleep.Wait(1000); var messageBox = WindowFinder.Search <BasicMessageBox>(Use.Title("MessageBoxTitle")); messageBox.OKButton.Unsafe.Click(); }
public void GetChildren_ByName_ReturnsAllThreeButtons() { var panel = UI.GetChild(By.AutomationId("CUI_NamesPanel"), From.Element(_testWindow)); var foundChild = UI.GetChildren(By.Name("B-", CompareKind.StartsWith), From.Element(panel), With.NoAssert()).ToList(); Assert.AreEqual(6, foundChild.Count); // Duplicated because the button and its content both has the name start with "B-" Assert.AreEqual("B-First", foundChild[0].Name); Assert.AreEqual("B-First", foundChild[1].Name); Assert.AreEqual("B-Second", foundChild[2].Name); Assert.AreEqual("B-Second", foundChild[3].Name); Assert.AreEqual("B-Third", foundChild[4].Name); Assert.AreEqual("B-Third", foundChild[5].Name); }
public void SlButtonAndEditAndDTP_ClickAndSetTextAndSelectedDateAsString_Succeeds() { BrowserWindowUnderTest b = BrowserWindowUnderTest.Launch(silverlightApplicationHtmlPageUrl); b.SetFocus(); b.Find <SilverlightButton>(By.AutomationId("button1")).Click(); SilverlightEdit oEdit = b.Find <SilverlightEdit>(By.AutomationId("textBox1")); oEdit.Text = "asddasdasdasdadasdadasdadadadasd"; SilverlightDatePicker dp = b.Find <SilverlightDatePicker>(By.AutomationId("datePicker1")); dp.SourceControl.SelectedDate = new DateTime(2011, 5, 11); b.Close(); }
public void SlComboBox_SelectItem_Succeeds() { var browserWindow = BrowserWindow.Launch(PageUrl); browserWindow.SetFocus(); var oCombo = browserWindow.Find <SilverlightComboBox>(By.AutomationId("comboBox1")); oCombo.SelectIndex(3); foreach (UITestControl temp in oCombo.Items) { Console.WriteLine(temp.Name); } browserWindow.Close(); }
public void Search_ForAMessageBox_FindsAndClosesIt() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var window = WindowFinder.Search <BasicWindow>(Use.AutomationId("CUI_TestApplication_MainWindow")); var button = UI.GetChild <BasicButton>(By.AutomationId("CUI_ShowMessageBox_Button"), From.Element(window)); button.Unsafe.Click(); DynamicSleep.Wait(1000); var messageBox = WindowFinder.Search <BasicMessageBox>(Use.Title("MessageBoxTitle")); messageBox.OKButton.Unsafe.Click(); window.CloseButton.Unsafe.Click(); }
public void TypeKey_AltF4OnTheWindow_ClosesTheWindow() { KeyboardEx.TypeKey(_testWindow, Key.F4, ModifierKeys.Alt).And.Wait(2000); var testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert().And.Timeout(2000)); Assert.IsNull(testWindow); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
public void SlComboBox_SelectItem_Succeeds() { BrowserWindowUnderTest.Launch(silverlightApplicationHtmlPageUrl); BrowserWindowUnderTest b = new BrowserWindowUnderTest("Home"); b.SetFocus(); SilverlightComboBox oCombo = b.Find <SilverlightComboBox>(By.AutomationId("comboBox1")); oCombo.SelectIndex(3); foreach (UITestControl temp in oCombo.Items) { Console.WriteLine(temp.Name); } b.Close(); }
public void GetDescendants_WithoutParameter_ReturnsAllCatchableChildElements() { var button = UI.GetChild(By.AutomationId("CUI_AutomationIdsPanel"), From.Element(_testWindow)); var descendants = UI.GetDescendants(From.Element(button)).ToList(); Assert.AreEqual(6, descendants.Count); Assert.AreEqual("CUI_Button1", descendants[0].AutomationId); Assert.AreEqual("First", descendants[1].Name); Assert.AreEqual("CUI_Button2", descendants[2].AutomationId); Assert.AreEqual("Second", descendants[3].Name); Assert.AreEqual("CUI_Button3", descendants[4].AutomationId); Assert.AreEqual("Third", descendants[5].Name); }
public void Click_ButtonInChildWindow_Succeeds() { BrowserWindow browserWindow = BrowserWindow.Launch(PageUrl); browserWindow.SetFocus(); SilverlightButton button = browserWindow.Find <SilverlightButton>(By.AutomationId("displayChildWindowButton")); button.Click(); SilverlightChildWindow childWindow = browserWindow.Find <SilverlightChildWindow>(By.AutomationId("TestChildWindow")); SilverlightButton okButton = childWindow.Find <SilverlightButton>(By.AutomationId("OKButton")); okButton.Click(); browserWindow.Close(); }
public void BringOnTop_TypesTextToDifferentWindows_TheWindowsGetsTheTextAccordingly() { var window1 = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow_1")); var window2 = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow_2")); var textBox1 = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(window1)); var textBox2 = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(window2)); WindowFocus.BringOnTop(window1); MouseEx.Click(window1); KeyboardEx.TypeText("First Window Text").And.Wait(1000); WindowFocus.BringOnTop(window2); MouseEx.Click(window2); KeyboardEx.TypeText("Second Window Text").And.Wait(1000); Assert.AreEqual("First Window Text", textBox1.Text); Assert.AreEqual("Second Window Text", textBox2.Text); }
public void Click_ChangeStatusBarVisibilityTwoTimes_DoesItAccordingly() { var statusBar = UI.GetChild(By.AutomationId("CUI_StatusBar"), From.Element(_testWindow)); Assert.IsTrue(statusBar.IsVisible); var viewMenuItem = UI.GetChild(By.AutomationId("CUI_ViewMenuItem"), From.Element(_testWindow)); MouseEx.Click(viewMenuItem).And.Wait(1000); var statusleisteMenuItem = UI.GetChild(By.AutomationId("CUI_ToggleStatusbarMenuItem"), From.Element(_testWindow)); MouseEx.Click(statusleisteMenuItem).And.Wait(1000); Assert.IsFalse(statusBar.IsVisible); MouseEx.Click(viewMenuItem).And.Wait(1000); statusleisteMenuItem = UI.GetChild(By.AutomationId("CUI_ToggleStatusbarMenuItem"), From.Element(_testWindow)); MouseEx.Click(statusleisteMenuItem).And.Wait(1000); Assert.IsTrue(statusBar.IsVisible); }
public void SlTab_TraverseSiblingsAndChildren_Succeeds() { BrowserWindowUnderTest b = BrowserWindowUnderTest.Launch(silverlightApplicationHtmlPageUrl); b.SetFocus(); SilverlightTab oTab = b.Find <SilverlightTab>(By.AutomationId("tabControl1")); oTab.SelectedIndex = 0; var btnOK = b.Find <SilverlightButton>(By.AutomationId("OKButtonInTabItem1")); ((SilverlightEdit)(btnOK.PreviousSibling)).Text = "blah blah hurray"; foreach (ControlBase control in oTab.GetChildren()) { if (control.GetType() == typeof(SilverlightEdit)) { ((SilverlightEdit)control).Text = "Text Changed"; break; } } Assert.IsTrue(((SilverlightTab)btnOK.Parent).SelectedItem == "tabItem1"); b.Close(); }
public DialogScreen NavigateToModalDialogScreen() { Find <WpfButton>(By.AutomationId("wimAM1xvJkqKO5jO9uUrSg")).Click(); return(NavigateTo <DialogScreen>()); }
public DialogScreen NavigateToNonModalDialogScreen() { Find <WpfButton>(By.AutomationId("i_mSaEucbU-ohslSj7y9aA")).Click(); return(NavigateTo <DialogScreen>()); }