public void ExitDialogSave() { WindowsElement toggle = session.FindElementByXPath("//Pane[@Name=\"PowerToys Settings\"]/*[@LocalizedControlType=\"toggleswitch\"]"); Assert.IsNotNull(toggle); bool initialToggleValue = toggle.GetAttribute("Toggle.ToggleState") == "1"; toggle.Click(); CloseSettings(); WindowsElement exitDialog = session.FindElementByName("Changes not saved"); Assert.IsNotNull(exitDialog); exitDialog.FindElementByName("Save").Click(); //check if window still opened WindowsElement powerToysWindow = session.FindElementByXPath("//Window[@Name=\"PowerToys Settings\"]"); Assert.IsNotNull(powerToysWindow); //check settings change JObject savedProps = GetProperties(); Assert.AreNotEqual(initialToggleValue, GetPropertyValue <bool>(savedProps, "fancyzones_shiftDrag")); //return initial app state toggle.Click(); }
public void ExitDialogCancel() { WindowsElement toggle = session.FindElementByXPath("//Pane[@Name=\"PowerToys Settings\"]/*[@LocalizedControlType=\"toggleswitch\"]"); Assert.IsNotNull(toggle); toggle.Click(); CloseSettings(); WindowsElement exitDialog = session.FindElementByName("Changes not saved"); Assert.IsNotNull(exitDialog); exitDialog.FindElementByName("Cancel").Click(); //check if window still opened WindowsElement powerToysWindow = session.FindElementByXPath("//Window[@Name=\"PowerToys Settings\"]"); Assert.IsNotNull(powerToysWindow); //check settings change JObject savedProps = GetProperties(); JObject initialProps = _initialSettingsJson["properties"].ToObject <JObject>(); Assert.AreEqual(GetPropertyValue <bool>(initialProps, "fancyzones_shiftDrag"), GetPropertyValue <bool>(savedProps, "fancyzones_shiftDrag")); //return initial app state toggle.Click(); SaveChanges(); }
public void AlarmSwitch() { WindowsElement alarmEntry = null; // Sprawdź, czy wcześniej utworzono wpis alarmu.W przeciwnym razie utwórz go, wywołując AlarmAdd() try { alarmEntry = session.FindElementByXPath($"//ListItem[starts-with(@Name, \"{AlarmInfo}\")]"); } catch { AlarmAdd(); alarmEntry = session.FindElementByXPath($"//ListItem[starts-with(@Name, \"{AlarmInfo}\")]"); } // Sprawdzanie poprawności działania przełącznika i ostateczne wyłączenie go Assert.IsNotNull(alarmEntry); WindowsElement alarmEntryToggleSwitch = alarmEntry.FindElementByAccessibilityId("AlarmToggleSwitch") as WindowsElement; Thread.Sleep(TimeSpan.FromSeconds(1)); Assert.IsTrue(alarmEntryToggleSwitch.Selected); //sprawdzenie czy przełącznik jest włączony alarmEntryToggleSwitch.Click(); //klikniecie i wyłączenie alarmu Assert.IsFalse(alarmEntryToggleSwitch.Selected); //sprawdzenie czy przełącznik jest wyłączony Thread.Sleep(TimeSpan.FromSeconds(1)); alarmEntryToggleSwitch.Click(); //klikniecie i ponowne włączenie alarmu Assert.IsTrue(alarmEntryToggleSwitch.Selected); //sprawdzenie czy przełącznik jest włączony Thread.Sleep(TimeSpan.FromSeconds(1)); alarmEntryToggleSwitch.Click(); //klikniecie i ponowne wyłączenie alarmu Assert.IsFalse(alarmEntryToggleSwitch.Selected); //sprawdzenie czy przełącznik jest wyłączony }
public void TwoPlusTwo() { buttonTwo.Click(); buttonPlus.Click(); buttonTwo.Click(); buttonEquals.Click(); }
public void MenuItemEdit() { // Select Edit -> Time/Date to get Time/Date from Notepad Assert.AreEqual(string.Empty, ourEditbox.Text); WindowsElement editMenu = ourSession.FindElementByName("Edit"); editMenu.Click(); ourSession.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Time/Date\")]").Click(); string timeDateString = ourEditbox.Text; Assert.AreNotEqual(string.Empty, timeDateString); // Select all text, copy, and paste it twice using MenuItem Edit // -> Select All, Copy, and Paste editMenu.Click(); ourSession.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Select All\")]").Click(); editMenu.Click(); ourSession.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Copy\")]").Click(); editMenu.Click(); ourSession.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Paste\")]").Click(); editMenu.Click(); ourSession.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Paste\")]").Click(); // Verify that the Time/Date string is duplicated Assert.AreEqual(timeDateString + timeDateString, ourEditbox.Text); }
public void Click() { // Click datePickerElement1 to show the picker and simply dismiss it datePickerElement1.Click(); var datePickerFlyout = session.FindElementByAccessibilityId("DatePickerFlyoutPresenter"); Assert.IsNotNull(datePickerFlyout); Assert.IsTrue(datePickerFlyout.Displayed); session.FindElementByAccessibilityId("DatePickerFlyoutPresenter").FindElementByAccessibilityId("DismissButton").Click(); System.Threading.Thread.Sleep(1000); // Click datePickerElement1 to show the picker and set the year to 2000 datePickerElement1.Click(); datePickerFlyout = session.FindElementByAccessibilityId("DatePickerFlyoutPresenter"); Assert.IsNotNull(datePickerFlyout); var yearLoopingSelector = datePickerFlyout.FindElementByAccessibilityId("YearLoopingSelector"); Assert.IsNotNull(yearLoopingSelector); var currentYear = yearLoopingSelector.Text; yearLoopingSelector.FindElementByName("2000").Click(); System.Threading.Thread.Sleep(1000); Assert.AreNotEqual(currentYear, yearLoopingSelector.Text); datePickerFlyout.FindElementByAccessibilityId("AcceptButton").Click(); }
public void TTXK_047_XuatKho(object ghichu, object sachIndex, object quantity) { button_Them.Click(); Thread.Sleep(100); SwitchToPopupWindow(); window_Them = session.FindElementByXPath("/Window[@ClassName=\"Window\"][@AutomationId=\"_ThongTinChiTiet_XK\"]"); var textboxes = window_Them.FindElementsByClassName("TextBox"); textboxes[0].SendKeys(ghichu.ToString()); OpenWindow_ThemSach(); Combobox_ChonSach((int)sachIndex); Thread.Sleep(100); NhapSoLuongSach((int)quantity); Thread.Sleep(100); session.FindElementByName("Thêm").Click(); Thread.Sleep(100); SwitchToPopupWindow(); session.FindElementByName("Đồng ý").Click(); SwitchToPopupWindow(); }
public void TestDefault1() { WindowsDriver <WindowsElement> Session = LaunchApp(); WindowsElement ComboElement = Session.FindElementByAccessibilityId("enumComboBox1"); ComboElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); Actions action; action = new Actions(Session); action.MoveToElement(ComboElement, 10, 50); action.Click(); action.Perform(); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowsElement CheckboxNullElement = Session.FindElementByName("Null"); CheckboxNullElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckboxNullElement.Click(); WindowsElement CheckboxBadElement = Session.FindElementByName("Bad"); CheckboxBadElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckboxBadElement.Click(); StopApp(Session); }
public void KH034_KhachHang_Add(object tenKH, object gioitinhIndex, object sdt, object diachi) { button_Them.Click(); SwitchToPopupWindow(); window_Them = session.FindElementByClassName("Popup"); var textboxes = window_Them.FindElementsByTagName("Edit"); textboxes[0].SendKeys((string)tenKH); Chon_GioiTinh((int)gioitinhIndex); Thread.Sleep(100); SwitchToPopupWindow(); textboxes[2].SendKeys((string)sdt); textboxes[3].SendKeys((string)diachi); window_Them.FindElementByName("Thêm").Click(); bool isNewKhachHangExists = table_KhachHang.FindElementsByTagName("DataItem").Any(row => { var cell_Ten = row.FindElementsByClassName("DataGridCell")[1]; return(cell_Ten.Text.Equals(tenKH)); }); Assert.IsTrue(isNewKhachHangExists); }
public void TestDefault1() { WindowsDriver <WindowsElement> Session = LaunchApp(); WindowsElement ButtonOKElement = Session.FindElementByName("OK"); ButtonOKElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowsElement ButtonCancelElement = Session.FindElementByName("Cancel"); ButtonCancelElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowsElement CheckAddYesElement = Session.FindElementByName("Add Yes"); CheckAddYesElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckAddYesElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowsElement CheckIsLocalizedElement = Session.FindElementByName("Is Localized"); CheckIsLocalizedElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckIsLocalizedElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckAddYesElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckIsLocalizedElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckIsLocalizedElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckAddYesElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowsElement CheckIsHorizontalElement = Session.FindElementByName("Horizontal"); CheckIsHorizontalElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckIsHorizontalElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckIsLocalizedElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowsElement ButtonSetCustomCommandsElement = Session.FindElementByName("Set Custom Commands"); ButtonSetCustomCommandsElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); CheckAddYesElement.Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); StopApp(Session); }
public void Click() { sliderElement1.Click(); Assert.IsTrue(int.Parse(sliderElement1.Text) > 45); // The value of the slider when the center is clicked should be greater than 45 and close to 50 sliderElement2.Click(); Assert.AreEqual("750", sliderElement2.Text); // The value of the slider when the center is clicked }
public static void ClearEditBox() { // Select all text and delete using keyboard shortcut Ctrl + A and Delete editBox.Click(); session.Keyboard.SendKeys(Keys.Control + "a" + Keys.Control); session.Keyboard.SendKeys(Keys.Delete); Assert.AreEqual(string.Empty, editBox.Text); }
public void Selected() { var originalState = checkBoxElement1.Selected; checkBoxElement1.Click(); Assert.AreNotEqual(originalState, checkBoxElement1.Selected); checkBoxElement1.Click(); Assert.AreEqual(originalState, checkBoxElement1.Selected); }
public static void OpenFancyZonesSettings() { WindowsElement fzNavigationButton = WaitElementByXPath("//Button[@Name=\"FancyZones\"]"); Assert.IsNotNull(fzNavigationButton); fzNavigationButton.Click(); fzNavigationButton.Click(); }
public void Click() { var radioButtonEventOutput = session.FindElementByAccessibilityId("Control1Output"); radioButtonElement1.Click(); Assert.AreEqual("You selected option 1.", radioButtonEventOutput.Text); radioButtonElement2.Click(); Assert.AreEqual("You selected option 2.", radioButtonEventOutput.Text); }
public void Click() { Assert.AreEqual("0", sliderElement1.Text); sliderElement1.Click(); Assert.AreNotEqual("0", sliderElement1.Text); Assert.AreEqual("800", sliderElement2.Text); sliderElement2.Click(); Assert.AreNotEqual("800", sliderElement1.Text); }
public void Text() { var originalValue = int.Parse(progressBarElement.Text); Assert.IsTrue(originalValue >= 0); clickAndHoldButton.Click(); Assert.AreEqual(originalValue + 1, int.Parse(progressBarElement.Text)); clickAndHoldButton.Click(); Assert.AreEqual(originalValue + 2, int.Parse(progressBarElement.Text)); }
public void ReplaceWord() { //NotepadTextArea.SendKeys("Hello World"); EditButton.Click(); DesktopSession.FindElementByAccessibilityId("23").Click(); DesktopSession.FindElementByAccessibilityId("1152").SendKeys("World"); DesktopSession.FindElementByAccessibilityId("1153").Clear(); DesktopSession.FindElementByAccessibilityId("1153").SendKeys("QA Engineers"); DesktopSession.FindElementByName("Reemplazar todo").Click(); DesktopSession.FindElementByAccessibilityId("2").Click(); }
public void Click() { var originalState = toggleSwitchElement.Selected; toggleSwitchElement.Click(); Assert.AreNotEqual(originalState, toggleSwitchElement.Selected); System.Threading.Thread.Sleep(1000); toggleSwitchElement.Click(); Assert.AreEqual(originalState, toggleSwitchElement.Selected); }
public void Click() { var buttonEventOutput = session.FindElementByAccessibilityId("Control1Output"); Assert.AreEqual("Off", buttonEventOutput.Text); toggleButtonElement.Click(); Assert.AreEqual("On", buttonEventOutput.Text); toggleButtonElement.Click(); Assert.AreEqual("Off", buttonEventOutput.Text); }
private static void OpenFancyZonesSettings() { WindowsElement fzNavigationButton = session.FindElementByXPath("//Button[@Name=\"FancyZones\"]"); Assert.IsNotNull(fzNavigationButton); fzNavigationButton.Click(); fzNavigationButton.Click(); ShortWait(); }
public void ZoneCount() { ShortWait(); OpenFancyZonesSettings(); WindowsElement editorButton = WaitElementByXPath("//Button[@Name=\"Edit zones\"]"); editorButton.Click(); WindowsElement minusButton = WaitElementByAccessibilityId("decrementZones"); WindowsElement zoneCount = WaitElementByAccessibilityId("zoneCount"); WindowsElement applyButton; int zoneCountQty; Assert.IsTrue(Int32.TryParse(zoneCount.Text, out zoneCountQty)); for (int i = zoneCountQty - 1, j = 0; i > -5; --i, ++j) { minusButton.Click(); Assert.IsTrue(Int32.TryParse(zoneCount.Text, out zoneCountQty)); Assert.AreEqual(Math.Max(i, 1), zoneCountQty); if (j == 0 || i == -4) { applyButton = WaitElementByAccessibilityId("ApplyTemplateButton"); applyButton.Click(); ShortWait(); Assert.AreEqual(zoneCountQty, getSavedZoneCount()); editorButton.Click(); minusButton = WaitElementByAccessibilityId("decrementZones"); zoneCount = WaitElementByAccessibilityId("zoneCount"); } } WindowsElement plusButton = WaitElementByAccessibilityId("incrementZones"); for (int i = 2; i < 45; ++i) { plusButton.Click(); Assert.IsTrue(Int32.TryParse(zoneCount.Text, out zoneCountQty)); Assert.AreEqual(Math.Min(i, 40), zoneCountQty); } applyButton = WaitElementByAccessibilityId("ApplyTemplateButton"); applyButton.Click(); ShortWait(); Assert.AreEqual(zoneCountQty, getSavedZoneCount()); }
public void Click() { // Click comboBoxElement1 to show the list and simply dismiss it var originalSelectedItem = comboBoxElement1.Text; comboBoxElement1.Click(); comboBoxElement1.FindElementByAccessibilityId("Light Dismiss").Click(); Assert.AreEqual(originalSelectedItem, comboBoxElement1.Text); // Click comboBoxElement1 to show the list and select an entry comboBoxElement1.Click(); comboBoxElement1.FindElementByName("Yellow").Click(); Assert.AreEqual("Yellow", comboBoxElement1.Text); }
public void Click() { var checkBoxEventOutput = session.FindElementByAccessibilityId("Control2Output"); Assert.AreEqual(string.Empty, checkBoxEventOutput.Text); checkBoxElement2.Click(); Assert.AreEqual("CheckBox is checked.", checkBoxEventOutput.Text); checkBoxElement2.Click(); Assert.AreEqual("CheckBox state is indeterminate.", checkBoxEventOutput.Text); checkBoxElement2.Click(); Assert.AreEqual("CheckBox is unchecked.", checkBoxEventOutput.Text); }
public static void OpenFancyZonesSettings() { try { WindowsElement fzNavigationButton = WaitElementByXPath("//Button[@Name=\"FancyZones\"]"); Assert.IsNotNull(fzNavigationButton); fzNavigationButton.Click(); fzNavigationButton.Click(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void GetElementText() { // Pivot Item element returns the name WindowsElement pivotItem = session.FindElementByAccessibilityId("StopwatchPivotItem"); Assert.IsTrue(pivotItem.Text.StartsWith("Stopwatch")); // StopWatchPivotItem text is Stopwatch or Stopwatch tab on older app version // Button element returns the button name WindowsElement button = session.FindElementByAccessibilityId("AddAlarmButton"); Assert.IsTrue(button.Text.Equals("Add new alarm") || button.Text.Equals("New")); // Add new alarm button is New on older app version button.Click(); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); // TextBlock element returns the text value WindowsElement textBlock = session.FindElementByAccessibilityId("EditAlarmHeader"); Assert.AreEqual("NEW ALARM", textBlock.Text); // List element returns the value of the selected list item WindowsElement list = session.FindElementByAccessibilityId("MinuteLoopingSelector"); Assert.AreEqual("00", list.Text); // TextBox element returns the text value WindowsElement textBox = session.FindElementByAccessibilityId("AlarmNameTextBox"); textBox.Clear(); Assert.AreEqual(string.Empty, textBox.Text); textBox.SendKeys("Test alarm name text box!"); Assert.AreEqual("Test alarm name text box!", textBox.Text); }
private void SetOpacity(WindowsElement editor, string key) { editor.Click(); //activate editor.SendKeys(OpenQA.Selenium.Keys.Control + OpenQA.Selenium.Keys.Backspace); //clear previous value editor.SendKeys(key); editor.SendKeys(OpenQA.Selenium.Keys.Enter); //confirm changes }
public void saveProblemTest() { DesiredCapabilities appCapabilities = new DesiredCapabilities(); string str = Environment.CurrentDirectory; appCapabilities.SetCapability("app", Environment.CurrentDirectory + "\\..\\..\\..\\Team_Agile\\bin\\Debug\\Team_Agile.exe"); WindowsDriver <WindowsElement> AlarmClockSession = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities); Assert.IsNotNull(AlarmClockSession); WindowsElement teacher_btn = AlarmClockSession.FindElementByName("教师"); Assert.IsNotNull(teacher_btn); teacher_btn.Click(); Thread.Sleep(2000); WindowsElement save_btn = AlarmClockSession.FindElementByName("导出"); Assert.IsNotNull(save_btn); save_btn.Click(); Thread.Sleep(2000); WindowsDriver <WindowsElement> save = (WindowsDriver <WindowsElement>)AlarmClockSession.SwitchTo().Window(AlarmClockSession.CurrentWindowHandle); WindowsElement ok_btn = save.FindElementByName("确定"); Assert.IsNotNull(ok_btn); ok_btn.Click(); AlarmClockSession.CloseApp(); Assert.IsTrue(File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "/Problem.xml")); }
public void ClickElement() { // Open a new alarm page and try clicking on visible and non-visible element in the time picker session.FindElementByAccessibilityId("AddAlarmButton").Click(); // initially visible element WindowsElement hourSelector = session.FindElementByAccessibilityId("HourLoopingSelector"); hourSelector.FindElementByName("8").Click(); Assert.AreEqual("8", hourSelector.Text); // initially non-visible element that is implicitly scrolled into view once clicked WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector"); minuteSelector.FindElementByName("30").Click(); Assert.AreEqual("30", minuteSelector.Text); // Return to main page and click on pivot items to switch between tabs DismissAddAlarmPage(); WindowsElement worldPivot = session.FindElementByAccessibilityId("WorldClockPivotItem"); WindowsElement alarmPivot = session.FindElementByAccessibilityId("AlarmPivotItem"); worldPivot.Click(); Assert.IsTrue(worldPivot.Selected); Assert.IsFalse(alarmPivot.Selected); alarmPivot.Click(); Assert.IsFalse(worldPivot.Selected); Assert.IsTrue(alarmPivot.Selected); }
public void SendModifierWindowsKey() { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "Root"); WindowsDriver <WindowsElement> desktopSession = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(desktopSession); // Launch action center using Window Keys + A editBox.SendKeys(OpenQA.Selenium.Keys.Command + "a" + OpenQA.Selenium.Keys.Command); WindowsElement actionCenterElement = null; // Before Windows 10 Anniversary and Creators Update Action Center name had lower case c for "center" try { actionCenterElement = desktopSession.FindElementByName("Action Center"); } catch { actionCenterElement = desktopSession.FindElementByName("Action center"); } Assert.IsNotNull(actionCenterElement); // Dismiss action center and cleanup the temporary session actionCenterElement.SendKeys(OpenQA.Selenium.Keys.Escape); editBox.Click(); desktopSession.Quit(); }