public void SetupBrushesPane() { // Select the Brushes toolbox to have the Brushes Pane sidebar displayed session.FindElementByAccessibilityId("Toolbox").FindElementByAccessibilityId("TopBar_ArtTools").Click(); brushesPane = session.FindElementByAccessibilityId("SidebarWrapper"); // Set eraser thickness to eraser width in pixel brushesPane.FindElementByAccessibilityId("Eraser3d").Click(); if (brushesPane.FindElementByAccessibilityId("Thickness").Text != eraserWidth) { brushesPane.FindElementByAccessibilityId("Thickness").SendKeys(Keys.Control + "a" + Keys.Control); brushesPane.FindElementByAccessibilityId("Thickness").SendKeys(eraserWidth + Keys.Enter); Thread.Sleep(TimeSpan.FromSeconds(1)); } // Ensure that the Pixel Pen is selected brushesPane.FindElementByAccessibilityId("PixelPencil3d").Click(); // Locate the drawing surface inkCanvas = session.FindElementByAccessibilityId("InteractorFocusWrapper"); // Locate the Undo button undoButton = session.FindElementByAccessibilityId("UndoIcon"); Assert.IsTrue(undoButton.Displayed); Assert.IsFalse(undoButton.Enabled); }
public void Test_Login_Valid(string object1, string object2) { header.FindElementByClassName("TextBox").SendKeys(Keys.LeftControl + "a"); header.FindElementByClassName("TextBox").SendKeys(object1); header.FindElementByClassName("PasswordBox").SendKeys(Keys.LeftControl + "a"); header.FindElementByClassName("PasswordBox").SendKeys(object2); header.FindElementByXPath("/Window[@AutomationId=\"_Login\"]/Button[@ClassName=\"Button\"][@Name=\"Login\"]").Click(); var result = header.FindElementByAccessibilityId("Warning").Text; Assert.AreNotEqual("Sai tài khoản hoặc mật khẩu", result); }
public void Test_Main_Can_GoBack() { var controlBar = header.FindElementByAccessibilityId("uc"); controlBar.FindElementByName("<").Click(); Thread.Sleep(500); session.SwitchTo().Window(session.WindowHandles.First()); var returnWindow = session.FindElementByAccessibilityId("_Login"); Assert.IsNotNull(returnWindow); }
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 }
static WindowsElement FindElement(this WindowsElement scroll, TypeEnum @enum, string eleName) { AppiumWebElement ele = null; switch (@enum) { case TypeEnum.AccessibilityId: { ele = scroll.FindElementByAccessibilityId(eleName); break; } case TypeEnum.Name: { ele = scroll.FindElementByName(eleName); break; } case TypeEnum.TagName: { ele = scroll.FindElementByTagName(eleName); break; } case TypeEnum.XPath: { ele = scroll.FindElementByXPath(eleName); break; } default: break; } return(ele as WindowsElement); }
private static void DismissSaveConfirmDialog() { try { WindowsElement closeSaveConfirmDialog = session.FindElementByAccessibilityId("CloseSaveConfirmDialog"); closeSaveConfirmDialog.FindElementByAccessibilityId("SecondaryBtnG3").Click(); } catch { } }
/// <summary> /// Initializes a new instance of the <see cref="WindowsNotificationScreen"/> class. /// </summary> /// <param name="desktopSession">Desktop session.</param> public WindowsNotificationScreen(WindowsDriver <WindowsElement> desktopSession) { try { WindowsElement notification = Utils.WaitUntilFindElement(desktopSession.FindElementByAccessibilityId, "NormalToastView"); this.titleText = notification.FindElementByAccessibilityId("TitleText"); this.messageText = notification.FindElementByAccessibilityId("MessageText"); this.dismissButton = notification.FindElementByAccessibilityId("DismissButton"); } catch (Exception) { Utils.WaitUntilFindElement(desktopSession.FindElementByName, "Action Center").Click(); var notification = Utils.WaitUntilFindElement(desktopSession.FindElementByName, "Notifications from Firefox Private Network VPN"); var latestNotification = notification.FindElementByClassName("ListViewItem"); this.titleText = latestNotification.FindElementByAccessibilityId("Title"); this.messageText = latestNotification.FindElementByAccessibilityId("Content"); this.dismissButton = latestNotification.FindElementByAccessibilityId("DismissButton"); } }
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 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 DrawWithPen() { PointerInputDevice penDevice = new PointerInputDevice(PointerKind.Pen); // Draw rectangle ABCD (consisting of AB, BC, CD, and DA lines) ActionSequence sequence = new ActionSequence(penDevice, 0); sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, A.X, A.Y, TimeSpan.Zero)); sequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact)); sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, B.X, B.Y, TimeSpan.Zero)); sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, C.X, C.Y, TimeSpan.Zero)); sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, D.X, D.Y, TimeSpan.Zero)); sequence.AddAction(penDevice.CreatePointerMove(inkCanvas, A.X, A.Y, TimeSpan.Zero)); sequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact)); session.PerformActions(new List <ActionSequence> { sequence }); // Fill the rectangle ABCD at the middle of the crosshair position (Point E) brushesPane.FindElementByAccessibilityId("FillBucket").Click(); ActionSequence fillSequence = new ActionSequence(penDevice, 0); fillSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, E.X, E.Y, TimeSpan.Zero)); fillSequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenContact)); fillSequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenContact)); session.PerformActions(new List <ActionSequence> { fillSequence }); // Erase by pressing PenEraser button along Point E X-Axis and Y-Axis to make the crosshair ActionSequence eraseSequence = new ActionSequence(penDevice, 0); eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, A.X - 5, E.Y, TimeSpan.Zero)); eraseSequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenEraser)); eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, B.X + 5, E.Y, TimeSpan.FromSeconds(.5))); eraseSequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenEraser)); eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, E.X, C.Y, TimeSpan.Zero)); eraseSequence.AddAction(penDevice.CreatePointerDown(PointerButton.PenEraser)); eraseSequence.AddAction(penDevice.CreatePointerMove(inkCanvas, E.X, B.Y, TimeSpan.FromSeconds(.5))); eraseSequence.AddAction(penDevice.CreatePointerUp(PointerButton.PenEraser)); session.PerformActions(new List <ActionSequence> { eraseSequence }); // Verify that the drawing operations took place Assert.IsTrue(undoButton.Displayed); Assert.IsTrue(undoButton.Enabled); }
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 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 override AppiumWebElement FindElement(WindowsElement element) { return(element.FindElementByAccessibilityId(Value)); }
private WindowsElement GetChildElementByAccessibilityID(WindowsElement parent, string id) { return((WindowsElement)parent.FindElementByAccessibilityId(id)); }