public void AddAlarm(string timeText) { if (timeText.Length > 0) { // Create a test alarm 1 minute after the read local time DateTimeFormatInfo fi = CultureInfo.CurrentUICulture.DateTimeFormat; DateTime alarmTime = DateTime.Parse(timeText, fi); alarmTime = alarmTime.AddMinutes(1.0); string hourString = alarmTime.ToString("%h", fi); string minuteString = alarmTime.ToString("mm", fi); string period = alarmTime.ToString("tt", fi); AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click(); AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear(); AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox") .SendKeys("Windows Application Driver Test Alarm"); WindowsElement periodSelector = null; try { periodSelector = AlarmClockSession.FindElementByAccessibilityId("PeriodSelector"); } catch (NoSuchElementException) { hourString = alarmTime.ToString("HH", fi); } periodSelector?.FindElementByName(period).Click(); AlarmClockSession.FindElementByAccessibilityId("HourSelector").FindElementByName(hourString).Click(); AlarmClockSession.FindElementByAccessibilityId("MinuteSelector").FindElementByName(minuteString) .Click(); Thread.Sleep(500); AlarmClockSession.FindElementByAccessibilityId("AlarmSaveButton").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 MoveAfterMerge() { OpenCreatorWindow("Columns", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); //create new zones new Actions(session).MoveToElement(thumbs[0]).Click().MoveByOffset(-(thumbs[0].Rect.X / 2), 0) .KeyDown(OpenQA.Selenium.Keys.Shift).Click().KeyUp(OpenQA.Selenium.Keys.Shift) .Perform(); thumbs = gridEditor.FindElementsByClassName("Thumb"); //merge zones ReadOnlyCollection <AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone"); Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10); AppiumWebElement mergeButton = gridEditor.FindElementByName("Merge zones"); Assert.IsNotNull(mergeButton, "Cannot merge: no merge button"); new Actions(session).Click(mergeButton).Perform(); //move thumb thumbs = gridEditor.FindElementsByClassName("Thumb"); AppiumWebElement thumb = thumbs[0]; Move(thumb, 0, false, true); Assert.IsTrue(thumb.Rect.Left <= moveStep); Assert.IsTrue(thumb.Rect.Right > 0); }
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 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 session.FindElementByAccessibilityId("CancelButton").Click(); 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 Test_BookList_Order_Create() { var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Nhà sách").Click(); var scrollView = header.FindElementByClassName("ScrollViewer"); scrollView.FindElementByClassName("Image").Click(); scrollView.FindElementByName("Thêm vào giỏ hàng").Click(); session.FindElementsByXPath("/Window[@Name=\"MainWindow\"][@AutomationId=\"_MainWindow\"]/Pane[@ClassName=\"Frame\"]/Button[@AutomationId=\"PART_Toggle\"]").Last().Click(); var popup = header.FindElementByClassName("Window"); popup.FindElementByName("Thanh toán").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); header.FindElementsByClassName("ComboBox")[0].SendKeys("Vũ Tuấn Hải"); header.FindElementsByClassName("ComboBox")[1].SendKeys(Keys.ArrowDown + Keys.ArrowDown); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var x = header.FindElementByName("Thêm hóa đơn thành công"); Assert.IsNotNull(x); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); }
protected static AppiumWebElement PowerToysTrayButton() { WindowsElement notificationOverflow = session.FindElementByName("Notification Overflow"); AppiumWebElement overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area"); AppiumWebElement powerToys = overflowArea.FindElementByXPath("//Button[contains(@Name, \"PowerToys\")]"); return(powerToys); }
public void AlarmAdd() { // Przejście do okna tworzenia Nowego Alarmu Thread.Sleep(TimeSpan.FromSeconds(1)); session.FindElementByAccessibilityId("AddAlarmButton").Click(); // Ustawienie nazwy session.FindElementByAccessibilityId("AlarmNameTextBox").Clear(); session.FindElementByAccessibilityId("AlarmNameTextBox").SendKeys(NewAlarmName); // Ustawienie godziny WindowsElement hourSelector = session.FindElementByAccessibilityId("HourLoopingSelector"); hourSelector.FindElementByName("10").Click(); Assert.AreEqual("10", hourSelector.Text); // Ustawienie minut WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector"); minuteSelector.FindElementByName("05").Click(); Assert.AreEqual("05", minuteSelector.Text); // Ustawienie powtórzeń session.FindElementByAccessibilityId("AlarmRepeatsToggleButton").Click(); Thread.Sleep(TimeSpan.FromSeconds(1)); session.FindElementByName("Poniedziałek").Click(); session.FindElementByName("Środa").Click(); session.FindElementByName("Sobota").Click(); Thread.Sleep(TimeSpan.FromSeconds(3)); session.FindElementByAccessibilityId("AlarmRepeatsToggleButton").Click(); Assert.AreEqual(AlarmRepeat, session.FindElementByAccessibilityId("AlarmRepeatsToggleButton").Text); // Ustawianie dźwięku session.FindElementByAccessibilityId("AlarmSoundButton").Click(); session.FindElementByName("Ksylofon").Click(); Assert.AreEqual("Dźwięk, Ksylofon, ", session.FindElementByAccessibilityId("AlarmSoundButton").Text); // Ustawianie długości drzemki session.FindElementByAccessibilityId("AlarmSnoozeCombobox").Click(); session.FindElementByName("20 minut").Click(); Assert.AreEqual("20 minut", session.FindElementByAccessibilityId("AlarmSnoozeCombobox").Text); // Zapisanie konfiguracji nowego alarmu session.FindElementByAccessibilityId("AlarmSaveButton").Click(); Thread.Sleep(TimeSpan.FromSeconds(2)); // Sprawdzenie czy nowy alarm ma odpowiednią godzinę, minuty, nazwę, dni w których alarm ma być powtarzany WindowsElement alarmEntry = session.FindElementByXPath($"//ListItem[starts-with(@Name, \"{AlarmInfo}\")]"); Assert.IsNotNull(alarmEntry); Assert.IsTrue(alarmEntry.Text.Contains("10")); Assert.IsTrue(alarmEntry.Text.Contains("05")); Assert.IsTrue(alarmEntry.Text.Contains(NewAlarmName)); Assert.IsTrue(alarmEntry.Text.Contains("Poniedziałek")); Assert.IsTrue(alarmEntry.Text.Contains("Środa")); Assert.IsTrue(alarmEntry.Text.Contains("Sobota")); }
private static void SetUpElements() { tab_KhoSach = menuBar.FindElementByName("Kho sách") as WindowsElement; tab_KhoSach.Click(); panel_KhoSach = mainAppHeader.FindElementByTagName("Pane") as WindowsElement; tab_XuatKho = panel_KhoSach.FindElementByName("Xuất kho") as WindowsElement; tab_XuatKho.Click(); button_Them = panel_KhoSach.FindElementByXPath("/Pane[@ClassName=\"Frame\"]/Pane[@ClassName=\"Frame\"]/Button[@ClassName=\"Button\"]") as WindowsElement; }
public void Test_BookList_Filter() { var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Nhà sách").Click(); var frame = header.FindElementByClassName("Frame"); frame.FindElementByAccessibilityId("PART_Toggle").Click(); var popup = header.FindElementByClassName("Popup"); popup.FindElementByName("Hài").Click(); frame.FindElementByAccessibilityId("PART_Toggle").Click(); var x = header.FindElementByName("Những Mẩu Chuyện Khôi Hài Ý Vị"); Assert.IsNotNull(x); frame.FindElementByAccessibilityId("PART_Toggle").Click(); popup.FindElementByName("Hài").Click(); frame.FindElementByAccessibilityId("PART_Toggle").Click(); }
public void TTTK015_CapNhatThongTin(object tenTK, object gioitinhIndex, object sdt, object diachi) { Open_Window_CapNhatThongTin(); var textboxes = window_CapNhatThongTin.FindElementsByClassName("TextBox"); textboxes[0].SendKeys(Keys.LeftControl + "a"); textboxes[0].SendKeys((string)tenTK); Chon_GioiTinh((int)gioitinhIndex); textboxes[3].SendKeys(Keys.LeftControl + "a"); textboxes[3].SendKeys((string)sdt); textboxes[5].SendKeys(Keys.LeftControl + "a"); textboxes[5].SendKeys((string)diachi); window_CapNhatThongTin.FindElementByName("Cập nhật").Click(); SwitchToPopupWindow(); Assert.AreEqual(session.FindElementByName((string)tenTK).Text, (string)tenTK); }
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); }
/// <summary> /// Close Firefox VPN client. /// </summary> public void CloseVPNClient() { var notification = Utils.WaitUntilFindElement(this.Session.FindElementByName, "Notification Chevron"); notification.Click(); var clientTray = this.Session.FindElementByName("Firefox Private Network VPN - Disconnected"); this.Session.Mouse.ContextClick(clientTray.Coordinates); WindowsElement menu = Utils.WaitUntilFindElement(this.Session.FindElementByClassName, "ContextMenu"); var exitItem = menu.FindElementByName("Exit"); exitItem.Click(); notification.Click(); }
protected static void OpenCreatorWindow(string tabName, string buttonId = "EditCustomButton") { try { editorWindow.FindElementByName(tabName).Click(); editorWindow.FindElementByAccessibilityId(buttonId).Click(); creatorWindow = editorWindow.FindElementByXPath("//Window"); Assert.IsNotNull(creatorWindow, "Creator window didn't open"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void OpenFancyZonesSettings() { try { AppiumWebElement fzNavigationButton = settingsWindow.FindElementByName("FancyZones"); Assert.IsNotNull(fzNavigationButton); fzNavigationButton.Click(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void PowerToysExit() { //open PowerToys context menu trayButton.Click(); isTrayOpened = true; WindowsElement notificationOverflow = session.FindElementByName("Notification Overflow"); AppiumWebElement overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area"); AppiumWebElement powerToys = overflowArea.FindElementByName("PowerToys"); Assert.IsNotNull(powerToys); new Actions(session).MoveToElement(powerToys).ContextClick().Perform(); ShortWait(); //exit session.FindElementByXPath("//MenuItem[@Name=\"Exit\"]").Click(); ShortWait(); //check PowerToys exited powerToys = null; try { notificationOverflow = session.FindElementByName("Notification Overflow"); overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area"); powerToys = overflowArea.FindElementByName("PowerToys"); } catch (OpenQA.Selenium.WebDriverException) { //expected, PowerToys shouldn't be here } LaunchPowerToys(); ShortWait(); Assert.IsNull(powerToys); }
public static void CloseSettings() { try { WindowsElement settings = session.FindElementByName("PowerToys Settings"); if (settings != null) { settings.Click(); settings.FindElementByName("Close").Click(); //settings.SendKeys(Keys.Alt + Keys.F4); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void FindNestedElement_ByName() { // Different Alarm & Clock application version uses different UI elements if (AlarmTabClassName == "ListViewItem") { WindowsElement ancestorElement = session.FindElementByClassName("ApplicationBar"); WindowsElement element = ancestorElement.FindElementByName("Add new alarm") as WindowsElement; Assert.IsNotNull(element); } else { var stopwatchPivotItem = session.FindElementByAccessibilityId(StopwatchTabAutomationId); stopwatchPivotItem.Click(); WindowsElement element = stopwatchPivotItem.FindElementByName("Reset") as WindowsElement; Assert.IsNotNull(element); } }
public void HighlightOpacityClearValueButton() { WindowsElement editor = session.FindElementByName("Zone Highlight Opacity (%)"); Assert.IsNotNull(editor); editor.Click(); //activate AppiumWebElement clearButton = editor.FindElementByName("Clear value"); Assert.IsNotNull(clearButton); /*element is not pointer- or keyboard interactable.*/ Actions action = new Actions(session); action.MoveToElement(clearButton).Click().Perform(); Assert.AreEqual("\r\n", editor.Text); }
public void KH035_NhapThieuDuLieu() { button_Them.Click(); SwitchToPopupWindow(); window_Them = session.FindElementByClassName("Popup"); Thread.Sleep(100); SwitchToPopupWindow(); 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("")); }); Assert.IsTrue(isNewKhachHangExists); }
public void AlarmAdd() { // Navigate to New Alarm page Thread.Sleep(TimeSpan.FromSeconds(1)); session.FindElementByAccessibilityId("AddAlarmButton").Click(); // Set alarm name session.FindElementByAccessibilityId("AlarmNameTextBox").Clear(); session.FindElementByAccessibilityId("AlarmNameTextBox").SendKeys(NewAlarmName); // Set alarm hour WindowsElement hourSelector = session.FindElementByAccessibilityId("HourLoopingSelector"); hourSelector.FindElementByName("3").Click(); Assert.AreEqual("3", hourSelector.Text); // Set alarm minute WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector"); minuteSelector.FindElementByName("55").Click(); Assert.AreEqual("55", minuteSelector.Text); // Save the newly configured alarm session.FindElementByAccessibilityId("AlarmSaveButton").Click(); Thread.Sleep(TimeSpan.FromSeconds(3)); // Verify that a new alarm entry is created with the given hour, minute, and name WindowsElement alarmEntry = session.FindElementByXPath($"//ListItem[starts-with(@Name, \"{NewAlarmName}\")]"); Assert.IsNotNull(alarmEntry); Assert.IsTrue(alarmEntry.Text.Contains("3")); Assert.IsTrue(alarmEntry.Text.Contains("55")); Assert.IsTrue(alarmEntry.Text.Contains(NewAlarmName)); // Verify that the alarm is active and deactivate it WindowsElement alarmEntryToggleSwitch = alarmEntry.FindElementByAccessibilityId("AlarmToggleSwitch") as WindowsElement; Assert.IsTrue(alarmEntryToggleSwitch.Selected); alarmEntryToggleSwitch.Click(); Assert.IsFalse(alarmEntryToggleSwitch.Selected); }
public void Test_BookManager_1_Add(string d1, string d2, string d3, string d4, string d5, string d6, string d7, string d8) { var img = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Images\tieng-viet-1.jpg"); var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Kho sách").Click(); var frame = header.FindElementByClassName("Frame"); frame.FindElementByName("Thông tin").Click(); frame.FindElementByAccessibilityId("AddBtn").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var tbs = header.FindElementsByClassName("TextBox"); tbs[0].SendKeys(d1); tbs[1].SendKeys(d2); tbs[2].SendKeys(d3); tbs[3].SendKeys(d4); tbs[4].SendKeys(d5); tbs[5].SendKeys(d7); tbs[6].SendKeys(d8); tbs[7].SendKeys(d6 + Keys.Enter); header.FindElementByAccessibilityId("ChooseImageBtn").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByName("Open"); var comboBox = header.FindElementByClassName("ComboBox"); comboBox.FindElementByClassName("Edit").SendKeys(img + Keys.Enter); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); Assert.AreEqual("Thêm sách thành công", header.FindElementByClassName("TextBlock").Text); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); var c = header.FindElementsByClassName("DataGridCell").Where(x => x.Text == d2).Count(); Assert.AreNotEqual(0, c); }
public void SendKeys_ModifierWindowsKey() { WindowsDriver <WindowsElement> desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId); Assert.IsNotNull(desktopSession); // Launch action center using Window Keys + A session.Keyboard.SendKeys(Keys.Command + "a" + Keys.Command); Thread.Sleep(TimeSpan.FromSeconds(2)); // Verify that Action Center pane is displayed WindowsElement actionCenterElement = desktopSession.FindElementByName("Action center"); Assert.IsNotNull(actionCenterElement); Assert.IsNotNull(actionCenterElement.FindElementByName("Tablet mode")); // Dismiss action center and cleanup the temporary session actionCenterElement.SendKeys(Keys.Escape); editBox.Click(); desktopSession.Quit(); }
public void Test_BookManager_3_Delete(string d) { var menubar = header.FindElementByClassName("MyMenuBar"); menubar.FindElementByName("Kho sách").Click(); var frame = header.FindElementByClassName("Frame"); frame.FindElementByName("Thông tin").Click(); header.FindElementByName("ID").Click(); header.FindElementByName("ID").Click(); var item = header.FindElementsByClassName("DataGridCell").Where(x => x.Text == d).SingleOrDefault(); item.Click(); frame.FindElementByName("Xóa").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); Assert.AreEqual("Xóa thành công", header.FindElementByClassName("TextBlock").Text); header.FindElementByName("Đồng ý").Click(); session.SwitchTo().Window(session.WindowHandles.First()); header = session.FindElementByClassName("Window"); }
public void DeleteMovieTest() { string username = "******"; string password = "******"; WindowsDriver <WindowsElement> session = Initialize(); session = WorkflowLogin(session, username, password); Assert.AreEqual(session.WindowHandles.Count, 1); // Main Page session.SwitchTo().Window(session.WindowHandles.Last()); Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0); WindowsElement eDeleteRow = session.FindElementsByClassName("DataGridRow").ElementAt(0); AppiumWebElement eDeleteButton = eDeleteRow.FindElementByName("Delete"); eDeleteButton.Click(); session.SwitchTo().Window(session.WindowHandles[0]); WindowsElement eYes = session.FindElementByName("Yes"); eYes.Click(); }
public void MergeZones() { OpenCreatorWindow("Columns", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); ReadOnlyCollection <AppiumWebElement> zones = gridEditor.FindElementsByClassName("GridZone"); ReadOnlyCollection <AppiumWebElement> thumbs = gridEditor.FindElementsByClassName("Thumb"); Assert.AreEqual(3, zones.Count); Assert.AreEqual(2, thumbs.Count); Move(zones[0], thumbs[0].Rect.X + thumbs[0].Rect.Width + 10, true, true, -(zones[0].Rect.Height / 2) + 10); AppiumWebElement mergeButton = gridEditor.FindElementByName("Merge zones"); Assert.IsNotNull(mergeButton, "Cannot merge: no merge button"); new Actions(session).Click(mergeButton).Perform(); Assert.AreEqual(2, gridEditor.FindElementsByClassName("GridZone").Count); Assert.AreEqual(1, gridEditor.FindElementsByClassName("Thumb").Count); }
public void ExitDialogExit() { 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("Exit").Click(); //check if window still opened try { WindowsElement powerToysWindow = session.FindElementByXPath("//Window[@Name=\"PowerToys Settings\"]"); Assert.IsNull(powerToysWindow); } catch (OpenQA.Selenium.WebDriverException) { //window is no longer available, which is expected } //return initial app state Init(); //check settings change JObject savedProps = GetProperties(); Assert.AreEqual(initialToggleValue, GetPropertyValue <bool>(savedProps, "fancyzones_shiftDrag")); }
public void CreateMesh1() { Driver.FindElementByName("Open...").Click(); System.Threading.Thread.Sleep(1000); action = new Actions(Driver); Assert.IsNotNull(action); action.SendKeys(@"D:\TechnoStar\Mazda\R2-IDI3_TS.jtdb"); action.SendKeys(Keys.Enter); action.Perform(); Driver.FindElementByName("Assembly").Click(); allParts = Driver.FindElementByName("All Parts"); var boltOld = allParts.FindElementByXPath("//TreeItem[@Name='bolt_old']"); Assert.IsNotNull(boltOld); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(boltOld); action.ContextClick(); action.SendKeys(Keys.Up); action.SendKeys(Keys.Enter); action.Build().Perform(); var headCyl = allParts.FindElementByXPath("//TreeItem[@Name ='HEAD-CYL']"); Assert.IsNotNull(headCyl); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(headCyl); action.ContextClick(); action.Build().Perform(); Driver.FindElementByXPath("//MenuItem[@Name ='Show Only']").Click(); var geometry = toolBar.FindElementByXPath("//TabItem[@Name ='Geometry']"); geometry.Click(); Driver.FindElementByXPath("//SplitButton[@Name ='Show Adjacent']").Click(); action = new Actions(Driver); Assert.IsNotNull(action); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter); action.Build().Perform(); toolBar.FindElementByName("Home").Click(); var find = Driver.FindElementByName("Find"); Assert.IsNotNull(find); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(find); action.MoveToElement(find, find.Size.Width / 2, find.Size.Height / 3 + 20).Click(); action.SendKeys(Keys.Down); action.SendKeys(Keys.Enter); action.Perform(); WindowsElement idBox = Driver.FindElementByAccessibilityId("1582"); Assert.IsNotNull(idBox); InputId(15254, idBox, action, Driver, find); var showAdj = jupiter.FindElementByName("Show Adjacent | Faces"); showAdj.FindElementByName("Stop Face").Click(); InputId(19885, idBox, action, Driver, find); InputId(16323, idBox, action, Driver, find); InputId(20597, idBox, action, Driver, find); InputId(20487, idBox, action, Driver, find); InputId(20596, idBox, action, Driver, find); InputId(20698, idBox, action, Driver, find); InputId(20694, idBox, action, Driver, find); Assert.AreEqual("8", Driver.FindElementByAccessibilityId("5105") .Text.Substring(9).Trim()); var numLayers = showAdj.FindElementByXPath("//Edit[@Name='Number of Layers']"); Assert.IsNotNull(numLayers); numLayers.Clear(); numLayers.SendKeys("100"); showAdj.FindElementByName("Apply").Click(); // Screenshot to compare ? var tools = toolBar.FindElementByName("Tools"); tools.Click(); var modelFilter = Driver.FindElementByName("Model Filter"); Assert.IsNotNull(modelFilter); action = new Actions(Driver); Assert.IsNotNull(action); action.MoveToElement(modelFilter); action.MoveToElement(modelFilter, -modelFilter.Size.Width / 2, modelFilter.Size.Height / 2).Click().Perform(); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); var group = jupiter.FindElementByName("Group"); var groupName = group.FindElementByAccessibilityId("1001"); Assert.IsNotNull(groupName); groupName.Clear(); groupName.SendKeys("WaterJacket"); Driver.FindElementByName("OK").Click(); Driver.FindElementByXPath("//Button[@Name='Application menu']").Click(); Driver.FindElementByName("Save As...").Click(); System.Threading.Thread.Sleep(1000); action = new Actions(Driver); action.SendKeys(@"D:\TechnoStar\Mazda\01_Groups.jtdb"); action.SendKeys(Keys.Enter); action.Perform(); }
static void Main(string[] args) { windowsMailProcess = new Process(); windowsMailProcess.StartInfo.UseShellExecute = true; windowsMailProcess.StartInfo.FileName = "2019-04-19_133828_114229_web.eml"; windowsMailProcess.Start(); Thread.Sleep(1500); DesiredCapabilities desktopCapabilities = new DesiredCapabilities(); desktopCapabilities.SetCapability("app", "Root"); desktopSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), desktopCapabilities); WindowsElement winMail = desktopSession.FindElementByName("Mail"); var document = winMail.FindElementByName("Message"); var scrollable = bool.Parse(document.GetAttribute("Scroll.VerticallyScrollable")); if (!scrollable) { document.GetScreenshot().SaveAsFile(@"c:\archine\appiumTest.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } else { Actions action = new Actions(desktopSession); var ScrollVerticalViewSize = double.Parse(document.GetAttribute("Scroll.VerticalViewSize")); var ScrollVerticalScrollPercen = double.Parse(document.GetAttribute("Scroll.VerticalScrollPercent")); var ParseBoundingRectangle = JObject.Parse("{" + document.GetAttribute("BoundingRectangle").Replace(' ', ',') + "}"); var BoundingRectangle = new Rectangle( ParseBoundingRectangle["Left"].Value <int>(), ParseBoundingRectangle["Top"].Value <int>(), ParseBoundingRectangle["Width"].Value <int>(), ParseBoundingRectangle["Height"].Value <int>()); var totalArea = Convert.ToInt32(System.Math.Floor((BoundingRectangle.Height * 100) / ScrollVerticalViewSize)); var steeps = Math.Floor((double)totalArea / (double)BoundingRectangle.Height); action.MoveByOffset(BoundingRectangle.X + 5, BoundingRectangle.Y + 5).Perform(); for (int i = 0; i < steeps; i++) { captureClip.Add(ArrayToBitmap(document.GetScreenshot().AsByteArray)); document.SendKeys(Keys.PageDown); Thread.Sleep(100); } MergedBitmaps(captureClip).Save(@"c:\archive\appiumTest2.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); captureClip.Clear(); } }
public override AppiumWebElement FindElement(WindowsElement element) { return(element.FindElementByName(Value)); }