public void AlarmsAndClockTest() { //Testing Universal Windows Platform Application: Alarms & Clock app //Setup options for Alarms & Clock app AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"); //Create WinAppDriver session var AlarmClockSession = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), options); //Use the session to control the application to add new alarm AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click(); AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear(); AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").SendKeys("Automated alarm test"); AlarmClockSession.FindElementByAccessibilityId("HourSelector").FindElementByName("9").Click(); AlarmClockSession.FindElementByAccessibilityId("AlarmRepeatsToggleButton").Click(); AlarmClockSession.FindElementByName("Monday").Click(); AlarmClockSession.FindElementByName("Wednesday").Click(); AlarmClockSession.FindElementByName("Friday").Click(); AlarmClockSession.FindElementByName("Close").Click(); AlarmClockSession.FindElementByName("Save").Click(); Assert.True(AlarmClockSession.FindElementByName("Automated alarm test, 9:00 AM, Monday, Wednesday, Friday, On").Displayed); }
public static void BaseSetup(TestContext context) { if (CalculatorSession == null) { // Launch the calculator app DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); appCapabilities.SetCapability("deviceName", "WindowsPC"); CalculatorSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(CalculatorSession); CalculatorSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); // Make sure we're in standard mode CalculatorSession.FindElementByAccessibilityId("NavButton").Click(); OriginalCalculatorMode = CalculatorSession.FindElementByAccessibilityId("FlyoutNav").Text; CalculatorSession.FindElementByName("Standard Calculator").Click(); // Use series of operation to locate the calculator result text element as a workaround CalculatorSession.FindElementByAccessibilityId("clearButton").Click(); CalculatorSession.FindElementByAccessibilityId("num7Button").Click(); CalculatorResult = CalculatorSession.FindElementByAccessibilityId("CalculatorResults"); } Assert.IsNotNull(CalculatorResult); }
public void SearchAdvanceMovieTest() { 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 eSearch = session.FindElementByAccessibilityId("btnSearchAdvance"); eSearch.Click(); session.SwitchTo().Window(session.WindowHandles[0]); WindowsElement eYear = session.FindElementByAccessibilityId("txtYear"); eYear.SendKeys("2021"); WindowsElement eSearchSubmit = session.FindElementByAccessibilityId("btnSearch"); eSearchSubmit.Click(); session.SwitchTo().Window(session.WindowHandles[0]); Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0); }
public static void DrawCircle(WindowsDriver <WindowsElement> session) { // Draw a circle with radius 300 and 40 (x, y) points const int radius = 300; const int points = 40; // Select the Brushes toolbox to have the Brushes Pane sidebar displayed and ensure that Marker is selected session.FindElementByAccessibilityId("Toolbox").FindElementByAccessibilityId("TopBar_ArtTools").Click(); session.FindElementByAccessibilityId("SidebarWrapper").FindElementByAccessibilityId("Marker3d").Click(); // Locate the drawing surface WindowsElement inkCanvas = session.FindElementByAccessibilityId("InteractorFocusWrapper"); // Draw the circle with a single touch actions OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchContact = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); ActionSequence touchSequence = new ActionSequence(touchContact, 0); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, 0, -radius, TimeSpan.Zero)); touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact)); for (double angle = 0; angle <= 2 * Math.PI; angle += 2 * Math.PI / points) { touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero)); } touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact)); session.PerformActions(new List <ActionSequence> { touchSequence }); // Verify that the drawing operations took place WindowsElement undoButton = session.FindElementByAccessibilityId("UndoIcon"); }
private void _Login(string login, string password) { var dc = new DesiredCapabilities(); dc.SetCapability("app", this._addmeFileName); _driver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), dc, new TimeSpan(0, 2, 0)); _driver.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 3, 0); _FillData("TextBox1", login); if (password != "password") { _driver.FindElementByAccessibilityId("TextBox2").SendKeys(password); } while (_driver.FindElementByAccessibilityId("Button3").Enabled == false) { _driver.FindElementByAccessibilityId("Button1").Click(); } for (int i = 0; i < 4; i++) { try { _driver.FindElementByAccessibilityId("Button3").Click(); System.Windows.Forms.SendKeys.Send("{ENTER}"); Thread.Sleep(1000); } catch { } } }
public void TestMethod1() { int human_action = 150; AppiumOptions appOptions = new AppiumOptions(); appOptions.AddAdditionalCapability("app", @"C:\Users\User01\source\repos\LoginaWHLoad\LoginaWHLoad\bin\Debug\LoginaWHLoad.exe"); WindowsDriver <WindowsElement> Driver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appOptions); Assert.AreEqual("White Star Login Form", Driver.Title); Console.WriteLine(Driver.Title); Thread.Sleep(human_action); Driver.FindElementByAccessibilityId("txtb_User").SendKeys("Vinicius Miranda de Pinho"); Thread.Sleep(human_action); Driver.FindElementByAccessibilityId("txtb_Password").SendKeys("12345678"); Thread.Sleep(human_action); Driver.FindElementByName("LOGIN").Click(); Thread.Sleep(human_action); var message = Driver.FindElementByAccessibilityId("lbl_loginsucess").Text; Console.WriteLine(message); Assert.AreEqual("Congratulations Sucess! ", message); Console.WriteLine("Compare message login"); Thread.Sleep(human_action); Driver.FindElementByName("EXIT").Click(); }
public static void Setup(TestContext context) { // Launch Calculator if it is not yet launched if (session == null || touchScreen == null) { session = Utility.CreateNewSession(CommonTestSettings.CalculatorAppId); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); try { header = session.FindElementByAccessibilityId("Header"); } catch { header = session.FindElementByAccessibilityId("ContentPresenter"); } Assert.IsNotNull(header); // Initialize touch screen object touchScreen = new RemoteTouchScreen(session); Assert.IsNotNull(touchScreen); } // Ensure that calculator is in standard mode if (!header.Text.Equals("Standard", StringComparison.OrdinalIgnoreCase)) { session.FindElementByAccessibilityId("NavButton").Click(); Thread.Sleep(TimeSpan.FromSeconds(1)); var splitViewPane = session.FindElementByClassName("SplitViewPane"); splitViewPane.FindElementByName("Standard Calculator").Click(); Thread.Sleep(TimeSpan.FromSeconds(1)); Assert.IsTrue(header.Text.Equals("Standard", StringComparison.OrdinalIgnoreCase)); } }
public static void TearDown() { WindowsElement inputBox = _session.FindElementByAccessibilityId("InputBox"); int textLength = inputBox.Text.Length; inputBox.Clear(); }
public void NavigateBack_ModernApp() { session = Utility.CreateNewSession(CommonTestSettings.AlarmClockAppId); session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); // Ensure alarms & clock are in Alarm Pivot view session.Navigate().Back(); session.DismissAlarmDialogIfThere(); try { session.FindElementByAccessibilityId("AlarmButton").Click(); } catch (InvalidOperationException) { session.FindElementByAccessibilityId("AlarmPivotItem").Click(); } // Navigate to New Alarm view session.FindElementByAccessibilityId("AddAlarmButton").Click(); Assert.IsNotNull(session.FindElementByAccessibilityId("EditAlarmHeader")); // Navigate back to the original view session.Navigate().Back(); session.DismissAlarmDialogIfThere(); Assert.IsNotNull(session.FindElementByAccessibilityId("AddAlarmButton")); }
public void TestMethod1() { if (calSession == null) { //DriverOptions driverOptions = new DriverOptions(); DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", calApp); appCapabilities.SetCapability("deviceName", "WindowsPC"); //Create a session to intract with Calculator windows application //calSession = new WindowsDriver<WindowsElement>(new Uri(appiumDriverURI), appCapabilities); calSession = new WindowsDriver <WindowsElement>(new Uri(appiumDriverURI), appCapabilities); //Automate Button and Get answer from Calculator //find by Name calSession.FindElement(By.Name("Nine")).Click(); calSession.FindElement(By.Name("One")).Click(); calSession.FindElement(By.Name("Two")).Click(); calSession.FindElement(By.Name("Three")).Click(); calSession.FindElement(By.Name("Multiply by")).Click(); //find by automation id calSession.FindElementByAccessibilityId("num9Button").Click(); calSession.FindElementByAccessibilityId("equalButton").Click(); //getting value from textbox string ExpectedValue = calSession.FindElementByAccessibilityId("CalculatorResults").Text; string ExpectedValue1 = ExpectedValue.Replace("Display is ", "").Replace(",", ""); //Testcases Assert.AreEqual(82107, Convert.ToInt64(ExpectedValue1)); } }
protected void Setup(string login, string password) { if (session == null) { AppiumOptions options = new AppiumOptions(); options.AddAdditionalCapability("app", AppId); options.AddAdditionalCapability("deviceName", "WindowsPC"); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), options); Assert.IsNotNull(session); session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); var usernameBox = session.FindElementByAccessibilityId("username_box"); usernameBox.SendKeys(login); var paswordBox = session.FindElementByAccessibilityId("password_box"); paswordBox.SendKeys(password); var loginButton = session.FindElementByAccessibilityId("loginButton"); loginButton.Click(); var loginWindowHandle = session.CurrentWindowHandle; int tries = 50; do //wait for main window { Thread.Sleep(100); tries--; } while (!session.WindowHandles.Any(h => h != loginWindowHandle) && tries > 0); Assert.IsTrue(session.WindowHandles.Any(h => h != loginWindowHandle)); session.SwitchTo().Window(session.WindowHandles.First()); } }
public void AssertEmptyAlarmList() { var element = driver.FindElementByAccessibilityId(EMPTY_LIST_MESSAGE); Assert.IsNotNull(element); // return this; }
public void MainWindowTest() { var project_explorer = session.FindElementByAccessibilityId("ProjectExplorerControl").FindElementByAccessibilityId("configuration_folder_view"); var tree_view_items = project_explorer.FindElementsByAccessibilityId("file_name"); Assert.AreEqual(tree_view_items.Count, 3); foreach (var i in tree_view_items) { Actions action = new Actions(session); action.DoubleClick(i); action.Perform(); break; } var TabsControl = session.FindElementByAccessibilityId("TabsControl"); var tab_items = TabsControl.FindElementsByAccessibilityId("TabContent"); Assert.AreEqual(tree_view_items.Count, 1); foreach (var i in tree_view_items) { var x = i.FindElementByAccessibilityId("configuration_folder_view"); break; } //menu_control.SendKeys("Matteo"); //session.FindElementByAccessibilityId("sayHelloButton").Click(); //var txtResult = session.FindElementByAccessibilityId("txtResult"); //Assert.AreEqual(txtResult.Text, $"Hello {menu_control.Text}"); }
public void NavigateForwardBrowser() { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId); session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); session.FindElementByAccessibilityId("addressEditBox").SendKeys(CommonTestSettings.MicrosoftUrl + OpenQA.Selenium.Keys.Enter); System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds var originalTitle = session.Title; Assert.AreNotEqual(String.Empty, originalTitle); // Navigate to different URLs session.FindElementByAccessibilityId("addressEditBox").SendKeys(CommonTestSettings.GitHubUrl + OpenQA.Selenium.Keys.Enter); System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds var newTitle = session.Title; Assert.AreNotEqual(originalTitle, newTitle); // Navigate back to original URL session.Navigate().Back(); System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds Assert.AreEqual(originalTitle, session.Title); // Navigate forward to original URL session.Navigate().Forward(); System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds Assert.AreEqual(newTitle, session.Title); session.Quit(); }
public void MasterDetail() { var capabilities = new AppiumOptions(); capabilities.AddAdditionalCapability(MobileCapabilityType.App, "8b831c56-bc54-4a8b-af94-a448f80118e7_sezxftbtgh66j!App"); capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows"); capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC"); var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); _appiumLocalService.Start(); var driver = new WindowsDriver <WindowsElement>(_appiumLocalService, capabilities); // tap on second item var el1 = driver.FindElementByName("Second item"); el1.Click(); var el2 = driver.FindElementByAccessibilityId("ItemText"); Assert.IsTrue(el2.Text == "Second item"); var backButton = driver.FindElementByAccessibilityId("Back"); backButton.Click(); var el3 = driver.FindElementByName("Fourth item"); Assert.IsTrue(el3 != null); driver.CloseApp(); }
private bool _FillData(string selector, string text) { while (_driver.FindElementByAccessibilityId(selector).Text != text) { _driver.FindElementByAccessibilityId(selector).Clear(); _driver.FindElementByAccessibilityId(selector).SendKeys(text); } return(true); }
public string getFirstHistoryEvent() { var docPanel = _session.FindElementByAccessibilityId("DockPanel"); var docPivot = docPanel.FindElementByAccessibilityId("DockPivot"); var historyLabel = docPivot.FindElementByAccessibilityId("HistoryLabel"); var HistoryList = historyLabel.FindElementByAccessibilityId("HistoryListView"); return(HistoryList.FindElementByClassName("ListViewItem").Text); }
public void TestMethod5() { var options = new AppiumOptions(); options.AddAdditionalCapability("app", @"C:\Program Files (x86)\M4Solutions\M4Solutions.exe"); var driver = new WindowsDriver <WindowsElement>(new Uri(" http://127.0.0.1:4723/"), options); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); var projectToOpen = @"E:\clients\mapcom\M4 Regression Test Automation\Test Project\Diversicom\ARVIG.prj"; System.Windows.Forms.Clipboard.SetText(projectToOpen); var projectCenterWindow = driver.FindElementByAccessibilityId("ProjectCenter"); var btnPickProject = projectCenterWindow.FindElementByAccessibilityId("btnPickProject"); btnPickProject.Click(); var openDialog = projectCenterWindow.FindElementByClassName("#32770"); var fileTextBox = openDialog.FindElementByAccessibilityId("1148"); fileTextBox.SendKeys(projectToOpen); var openButton = openDialog.FindElementByAccessibilityId("1"); openButton.Click(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); var mainWindow = driver.FindElementByAccessibilityId("MDIForm1"); wait.Until(ExpectedConditions.TextToBePresentInElement(mainWindow, "M4 - ARVIG")); wait.Until(ExpectedConditions.ElementExists(By.Name("COUNTIES.msi"))); var eyes = new Eyes(); eyes.ApiKey = "lFMnO9e1nbFQEdhebrDmhEBOqB7jXUXJGogj103lRWAzM110"; eyes.SetAppEnvironment("Windows 10", null); try { eyes.Open("AppiumPractice", "TestMethod5"); Thread.Sleep(3000); var currentAppScreenshot = driver.GetScreenshot(); eyes.CheckImage(currentAppScreenshot.AsByteArray, "Project Finished Loading"); eyes.Close(); } finally { eyes?.AbortIfNotClosed(); driver.Quit(); } }
public void GetWindowHandlesModernApp() { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId); WindowsDriver <WindowsElement> multiWindowsSession = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(multiWindowsSession); Assert.IsNotNull(multiWindowsSession.SessionId); var windowHandlesBefore = multiWindowsSession.WindowHandles; Assert.IsNotNull(windowHandlesBefore); Assert.IsTrue(windowHandlesBefore.Count > 0); // Preserve previously opened Edge window(s) and only manipulate newly opened windows List <String> previouslyOpenedEdgeWindows = new List <String>(windowHandlesBefore); previouslyOpenedEdgeWindows.Remove(multiWindowsSession.CurrentWindowHandle); // Open a new window // The menu item names have changed between Windows 10 and the anniversary update // account for both combinations. try { multiWindowsSession.FindElementByAccessibilityId("m_actionsMenuButton").Click(); multiWindowsSession.FindElementByAccessibilityId("m_newWindow").Click(); } catch (System.InvalidOperationException) { multiWindowsSession.FindElementByAccessibilityId("ActionsMenuButton").Click(); multiWindowsSession.FindElementByAccessibilityId("ActionsMenuNewWindow").Click(); } System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds var windowHandlesAfter = multiWindowsSession.WindowHandles; Assert.IsNotNull(windowHandlesAfter); Assert.AreEqual(windowHandlesBefore.Count + 1, windowHandlesAfter.Count); // Preserve previously opened Edge Windows by only closing newly opened windows List <String> newlyOpenedEdgeWindows = new List <String>(windowHandlesAfter); foreach (var previouslyOpenedEdgeWindow in previouslyOpenedEdgeWindows) { newlyOpenedEdgeWindows.Remove(previouslyOpenedEdgeWindow); } foreach (var windowHandle in newlyOpenedEdgeWindows) { multiWindowsSession.SwitchTo().Window(windowHandle); multiWindowsSession.Close(); } multiWindowsSession.Quit(); }
/// <summary> /// Make calculations of given numbers /// </summary> /// <param name="action">Actions to perform</param> /// <param name="first_argument">First number for calculations</param> /// <param name="second_argument">Second number for calculations</param> /// <returns>Result on display</returns> public string GetCalculationResults(string action, int first_argument = 0, int second_argument = 0) { _driver.FindElementByName(appName); _driver.FindElementByAccessibilityId(numberButtons(first_argument)).Click(); _driver.FindElementByAccessibilityId(action).Click(); _driver.FindElementByAccessibilityId(numberButtons(second_argument)).Click(); _driver.FindElementByName("Equals").Click(); return(_driver.FindElementByAccessibilityId("CalculatorResults").Text); }
public void T001_左クリックする() { var button = _session.FindElementByAccessibilityId("button1"); var actions = new Actions(_session); actions.Click(button); // Buttonを左クリック actions.Perform(); // 実行 System.Threading.Thread.Sleep(1000); }
public void CreateNewStickyNote() { var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; const int stickyNoteWidth = 1000; const int stickyNoteHeight = 1000; const int stickyNotePositionX = 100; const int stickyNotePositionY = 100; // Preserve existing or previously opened Sticky Notes by keeping track of them on initialize var openedStickyNotesWindowsBefore = session.FindElementsByClassName("ApplicationFrameWindow"); Assert.IsNotNull(openedStickyNotesWindowsBefore); Assert.IsTrue(openedStickyNotesWindowsBefore.Count > 0); // Create a new Sticky Note by pressing Ctrl + N openedStickyNotesWindowsBefore[0].SendKeys(Keys.Control + "n" + Keys.Control); Thread.Sleep(TimeSpan.FromSeconds(2)); var openedStickyNotesWindowsAfter = session.FindElementsByClassName("ApplicationFrameWindow"); Assert.IsNotNull(openedStickyNotesWindowsAfter); Assert.AreEqual(openedStickyNotesWindowsBefore.Count + 1, openedStickyNotesWindowsAfter.Count); // Identify the newly opened Sticky Note by removing the previously opened ones from the list List <WindowsElement> openedStickyNotes = new List <WindowsElement>(openedStickyNotesWindowsAfter); foreach (var preExistingStickyNote in openedStickyNotesWindowsBefore) { openedStickyNotes.Remove(preExistingStickyNote); } Assert.AreEqual(1, openedStickyNotes.Count); // Create a new session based from the newly opened Sticky Notes window var newStickyNoteWindowHandle = openedStickyNotes[0].GetAttribute("NativeWindowHandle"); newStickyNoteWindowHandle = (int.Parse(newStickyNoteWindowHandle)).ToString("x"); // Convert to Hex AppiumOptions appCapabilities = new AppiumOptions(); appCapabilities.AddAdditionalCapability("appTopLevelWindow", newStickyNoteWindowHandle); appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); newStickyNoteSession = new WindowsDriver <WindowsElement>(serverUri, appCapabilities); Assert.IsNotNull(newStickyNoteSession); // Resize and re-position the Sticky Notes window we are working with newStickyNoteSession.Manage().Window.Size = new Size(stickyNoteWidth, stickyNoteHeight); newStickyNoteSession.Manage().Window.Position = new Point(stickyNotePositionX, stickyNotePositionY); // Verify that this Sticky Notes is indeed new. Newly created Sticky Notes has both // RichEditBox and InkCanvas in the UI tree. Once modified by a pen or key input, // it will only contain one or the other. Assert.IsNotNull(newStickyNoteSession.FindElementByAccessibilityId("RichEditBox")); inkCanvas = newStickyNoteSession.FindElementByAccessibilityId("InkCanvas"); Assert.IsNotNull(inkCanvas); }
public void Test() { var btnPrev = session.FindElementByAccessibilityId("btnPrev"); var btnNext = session.FindElementByAccessibilityId("btnNext"); btnNext.Click(); btnNext.Click(); btnPrev.Click(); btnPrev.Click(); btnPrev.Click(); }
public void Test_Application_Add_Item_Dialog_AddsNewItem() { var capabilities = new AppiumOptions(); capabilities.AddAdditionalCapability(MobileCapabilityType.App, @"C:\temp\appium-hol\AppsToTest\WinForms\CarvedRock.exe"); capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows"); capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC"); //start the application var driver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities); // click add var addButton = driver.FindElementByName("AddNewItem"); addButton.Click(); // verify we are showing the dialog var AddDialogWindow = driver.FindElementByAccessibilityId("NewItemForm"); var textLabel1 = AddDialogWindow.FindElementByAccessibilityId("label1"); Assert.IsTrue(textLabel1 != null); var inputFieldItem = AddDialogWindow.FindElementByName("ItemText"); inputFieldItem.Clear(); inputFieldItem.SendKeys("New Item Text"); var InputFieldItemDetail = AddDialogWindow.FindElementByName("ItemDetail"); InputFieldItemDetail.Clear(); InputFieldItemDetail.SendKeys("New item details text"); //close the dialog var AddButton = AddDialogWindow.FindElementByAccessibilityId("button1"); AddButton.Click(); // scroll the list to the end var scrollDownButton = driver.FindElementByAccessibilityId("DownButton"); scrollDownButton.Click(); scrollDownButton.Click(); // verify we can find the item in the list var listview = driver.FindElementByAccessibilityId("listView1"); var newElement = listview.FindElementByName("New Item Text"); Assert.IsTrue(newElement != null); //stop the application driver.CloseApp(); driver.Dispose(); }
public void Division() { // Find the buttons by their accessibility ids and click them in sequence to perform 88 / 11 = 8 session.FindElementByAccessibilityId("num8Button").Click(); session.FindElementByAccessibilityId("num8Button").Click(); session.FindElementByAccessibilityId("divideButton").Click(); session.FindElementByAccessibilityId("num1Button").Click(); session.FindElementByAccessibilityId("num1Button").Click(); session.FindElementByAccessibilityId("equalButton").Click(); Assert.AreEqual("8", GetCalculatorResultText()); }
private void SelectBackgroundColor(bool black) { var blackWhiteButton = _session.FindElementByAccessibilityId("ChangeBackgroundButton"); var buttonState = blackWhiteButton.Text; if ((buttonState == "Background White" && black) || (buttonState == "Background Black" && !black)) { blackWhiteButton.Click(); } }
public MainPageObject AssertEmptyAlarmList() { WaitForElementById(10, EMPTY_LIST_MESSAGE); var element = driver.FindElementByAccessibilityId(EMPTY_LIST_MESSAGE); Assert.IsNotNull(element); return(this); }
// Concate the text public string GetResults(string text, string resultName) { try { result = _driver.FindElementByAccessibilityId(resultName); return(result.Text.Replace(text, string.Empty).Trim()); } catch (InvalidOperationException ex) { throw new InvalidOperationException($"resultName must be of the type AccessibilityId. {ex}"); } }
public void WindowsAlarm() { // Launch the Alarms &Clock app DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"); var AlarmClockSession = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities); // Use the session to control the app AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click(); AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear(); }
public void CheckValidPath() { System.Threading.Thread.Sleep(TimeSpan.FromSeconds(settings.DefaultWaitTime)); _driver.FindElementByAccessibilityId("folderTXTBX").Click(); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(settings.DefaultWaitTime)); string folderText = _driver.FindElementByAccessibilityId("folderTXTBX").Text; Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory).ToString(), folderText); }