public int LiczbaWierszyOstatni() { string nazwa; driver.FindElementByName("Panel danych"); nazwa = driver.FindElementByXPath("//Custom[@Name=\"Panel danych\"]/*[last()]").GetAttribute("Name"); return(Int32.Parse(Regex.Match(nazwa.ToString(), @"\d+").Value)); }
public void VerifyMultiplicationWorksAsExpected() { session.FindElementByXPath("//Button[@Name='Six']").Click(); session.FindElementByXPath("//Button[@Name='Multiply by']").Click(); session.FindElementByXPath("//Button[@Name='Seven']").Click(); session.FindElementByXPath("//Button[@Name='Equals']").Click(); Console.WriteLine(session.FindElementByAccessibilityId("CalculatorResults").Text); Assert.IsTrue(session.FindElementByAccessibilityId("CalculatorResults").Text.Equals("Display is 42")); }
public void Test1() { var textBoxLocateFolder = driver.FindElementByXPath("/Window/Pane/Pane/ComboBox/Edit[@ClassName='Edit']"); textBoxLocateFolder.SendKeys(@"C:\Program Files\7-Zip\"); textBoxLocateFolder.SendKeys(Keys.Enter); var listBoxFiles = driver.FindElementByAccessibilityId("1001"); listBoxFiles.SendKeys(Keys.Control + 'a'); var Addbutton = driver.FindElementByXPath("/Window/ToolBar/Button[@Name='Add']"); Addbutton.Click(); Thread.Sleep(1000); var windowAddToArchive = desktopDriver.FindElementByName("Add to Archive"); var textBoxArchiveName = windowAddToArchive.FindElementByXPath("/Window/ComboBox/Edit[@Name='Archive:']"); Random rnd = new Random(); string archiveFileName = workDir + "\\" + rnd.Next(10000000) + ".7z"; textBoxArchiveName.SendKeys(archiveFileName); var DictSize = windowAddToArchive.FindElementByXPath("/Window/ComboBox[@Name='Dictionary size:']"); DictSize.SendKeys(Keys.End); var WordSize = windowAddToArchive.FindElementByXPath("/Window/ComboBox[@Name='Word size:']"); WordSize.SendKeys(Keys.End); var buttonAddToArchiveOK = windowAddToArchive.FindElementByXPath("/Window/Button[@Name='OK']"); buttonAddToArchiveOK.Click(); Thread.Sleep(1000); textBoxLocateFolder.SendKeys(archiveFileName + Keys.Enter); var buttonExtract = driver.FindElementByXPath("/Window/ToolBar/Button[@Name='Extract']"); buttonExtract.Click(); var buttonExtractOK = driver.FindElementByXPath("/Window/Window/Button[@Name='OK']"); buttonExtractOK.Click(); Thread.Sleep(1000); string executable7ZipOriginal = @"C:\Program Files\7-Zip\7zFM.exe"; string executable7ZipExtracted = workDir + @"\7zFM.exe"; FileAssert.AreEqual(executable7ZipOriginal, executable7ZipExtracted); }
public void ModifferDevis() { if (session == null) { Thread.Sleep(3000); DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", Meca); appCapabilities.SetCapability("deviceName", "WindowsPC"); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); Thread.Sleep(10000); session.SwitchTo().Window(session.WindowHandles[0]); // LeftClick on "quotesTileButton" at (84,61) string xp1 = "/Pane[@Name=\"Bureau 1\"][@ClassName=\"#32769\"]/Window[@AutomationId=\"HostForm\"][@Name=\"EBP MéCa MRoad Evolution 2019 (OL Technology)\"]/Pane[@AutomationId=\"WorkshopDashboardPage\"]/Pane[starts-with(@ClassName,\"WindowsForms10\")]/Pane[starts-with(@ClassName,\"WindowsForms10\")]/Pane[@AutomationId=\"DashboardTileButton\"]/Button[@AutomationId=\"quotesTileButton\"]"; var winElem1 = session.FindElementByXPath(xp1); if (winElem1 != null) { winElem1.Click(); } else { Console.WriteLine($"Failed to find element {xp1}"); return; } Thread.Sleep(4000); session.FindElementByName("Modifier").Click(); Thread.Sleep(TimeSpan.FromSeconds(4)); session.SwitchTo().Window(session.WindowHandles[0]); Thread.Sleep(TimeSpan.FromSeconds(8)); // LeftClick on "hayat" at (76,17) Console.WriteLine("LeftClick on \"hayat\" at (76,17)"); string xp2 = "/Pane[@Name=\"Bureau 1\"][@ClassName=\"#32769\"]/Window[@AutomationId=\"TradeDocumentEntryFormBase\"][@Name=\"Devis [DE00000020] du 09/04/2019\"]/Pane[@AutomationId=\"layoutManager\"][@Name=\"The XtraLayoutControl\"]/Edit[@AutomationId=\"thirdNameStringLookupEditor\"][@Name=\"hayat\"]"; var winElem2 = session.FindElementByXPath(xp2); if (winElem2 != null) { winElem2.Click(); } else { Console.WriteLine($"Failed to find element {xp2}"); return; } winElem2.SendKeys("laura"); } }
private void Button1_Click(object sender, EventArgs e) { //Close NotePad(NotePad 닫기) // "/Pane[@ClassName=\"#32769\"][@Name=\"데스크톱 1\"]/Window[@ClassName=\"Notepad\"][@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]" //// //var gameElement = _deskTopSessoin.FindElementsByXPath("//ListItem[@ClassName=\"GridViewItem\"]/Button[@AutomationId=\"_rootGrid\"]/Image[@AutomationId=\"_image\"]"); this.initDeskTopSession_Explicit(); try { //아래 코드 테스트 문제 없음... //var element = _deskTopSession.FindElementByXPath("//Window[@Name=\"전원 관리 옵션 설정 편집\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]"); //element.Click(); //below is okay //var element = _deskTopSession.FindElementByXPath("//Window[@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]"); //element.Click(); //below is Okay var find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]"); var notepad_close_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element)); notepad_close_button.Click(); var save_ignore_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ByAccessibilityId.AccessibilityId("CommandButton_7"))); save_ignore_button.Click(); //element.Click(); //var element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"Notepad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@AutomationId=\"Close\"]"); //element.Click(); //var element = _deskTopSession.FindElementByXPath("//Window[@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@AutomationId=\"Close\"]"); //element.Click(); //var find_element = _deskTopSession.FindElementByXPath("//Window[@ClassName=\"NotePad\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@AutomationId=\"Close\"]"); //var find_element = _deskTopSession.FindElementByXPath("//Window[@Name=\"*제목 없음 - Windows 메모장\"]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"닫기\"]"); //var notepad_close_button = _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(find_element)); //notepad_close_button.Click(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("Full Stacktrace: {0}", ex.ToString())); } }
public void Multiplication() { _driver.FindElementByXPath("//Button[@Name='Nine']").Click(); _driver.FindElementByXPath("//Button[@Name='Multiply by']").Click(); _driver.FindElementByXPath("//Button[@Name='Nine']").Click(); _driver.FindElementByXPath("//Button[@Name='Equals']").Click(); Assert.AreEqual("81", GetCalculatorResultText()); }
public static WindowsElement FindElementByAbsoluteXPath( this WindowsDriver <WindowsElement> desktopSession, string xPath, int nTryCount = 3) { WindowsElement uiTarget = null; while (nTryCount-- > 0) { try { uiTarget = desktopSession.FindElementByXPath(xPath); } catch { } if (uiTarget != null) { break; } else { System.Threading.Thread.Sleep(400); } } return(uiTarget); }
public static void Setup(TestContext context) { // Cleanup leftover objects from previous test if exists TearDown(); // Launch the Edge browser app DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId); session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Initialize touch screen object touchScreen = new RemoteTouchScreen(session); Assert.IsNotNull(touchScreen); // Track the Microsoft Edge starting page title to be used to initialize all test cases System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds startingPageTitle = session.Title; // Handle Microsoft Edge restored state by starting fresh if (startingPageTitle.StartsWith("Start fresh and ")) { try { session.FindElementByXPath("//Button[@Name='Start fresh']").Click(); System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds startingPageTitle = session.Title; } catch { } } }
// 指定の要素が検索できるまで待機する public static WindowsElement WaitElementByAbsoluteXPath(WindowsDriver <WindowsElement> root, string xPath, int nTryCount = 15) { WindowsElement uiTarget = null; while (nTryCount-- > 0) { try { uiTarget = root.FindElementByXPath(xPath); } catch { } if (uiTarget != null) { break; } else { System.Threading.Thread.Sleep(500); } } return(uiTarget); }
public static void Setup(TestContext context) { // Launch Edge browser app if it is not yet launched if (session == null || touchScreen == null || !Utility.CurrentWindowIsAlive(session)) { // Cleanup leftover objects from previous test if exists TearDown(); // Launch the Edge browser app session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private"); session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1)); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); // Initialize touch screen object touchScreen = new RemoteTouchScreen(session); Assert.IsNotNull(touchScreen); } // Track the Microsoft Edge starting page title to be used to initialize all test cases Thread.Sleep(TimeSpan.FromSeconds(1)); startingPageTitle = session.Title; // Handle Microsoft Edge restored state by starting fresh if (startingPageTitle.StartsWith("Start fresh and ")) { try { session.FindElementByXPath("//Button[@Name='Start fresh']").Click(); Thread.Sleep(TimeSpan.FromSeconds(3)); startingPageTitle = session.Title; } catch { } } }
public static void WaitUntilNotShown(this WindowsDriver <WindowsElement> session, TypeEnum type, string element) { while (true) { try { switch (type) { case TypeEnum.AccessibilityId: session.FindElementByAccessibilityId(element); break; case TypeEnum.XPath: session.FindElementByXPath(element); break; case TypeEnum.Name: session.FindElementByName(element); break; case TypeEnum.TagName: session.FindElementByTagName(element); break; default: break; } } catch (Exception) { break; } } }
public void Multiplication() { // Find the buttons by their names using XPath and click them in sequence to perform 9 x 9 = 81 session.FindElementByXPath("//Button[@Name='Nine']").Click(); session.FindElementByXPath("//Button[@Name='Multiply by']").Click(); session.FindElementByXPath("//Button[@Name='Nine']").Click(); session.FindElementByXPath("//Button[@Name='Equals']").Click(); Assert.AreEqual("81", GetCalculatorResultText()); }
//Trying to find element by XPath protected static WindowsElement WaitElementByXPath(string xPath, double maxTime = 10) { WindowsElement result = null; Stopwatch timer = new Stopwatch(); timer.Start(); while (timer.Elapsed < TimeSpan.FromSeconds(maxTime)) { try { result = session.FindElementByXPath(xPath); } catch { } return(result); } return(null); }
public static void fecharAplicacao() { // Close the application and delete the session if (session != null) { try { session.FindElementByXPath(WindowsObjects.JanelaPrincipal.ICONE_FECHAR_APLICACAO).Click(); session.FindElementByXPath("//Button[@Name='OK']").Click(); session = null; } catch (Exception e) { string message = e.Message; } } }
public void Multiplication() { SelectCalculator(CalculatorType.Standard); ClearCalcInput(); _driver.FindElementByXPath("//Button[@Name=\"Nine\"]").Click(); _driver.FindElementByXPath("//Button[@Name='Multiply by']").Click(); _driver.FindElementByXPath("//Button[@Name='Nine']").Click(); _driver.FindElementByXPath("//Button[@Name='Equals']").Click(); Assert.AreEqual("81", GetStandardCalculatorResultText()); }
public void Multiplication() { ClearCalcInput(); //OpenQA.Selenium.WebDriverException: Unexpected error. Unimplemented Command: xpath locator strategy is not supported _driver.FindElementByXPath("//Button[@Name=\"Nine\"]").Click(); _driver.FindElementByXPath("//Button[@Name='Multiply by']").Click(); _driver.FindElementByXPath("//Button[@Name='Nine']").Click(); _driver.FindElementByXPath("//Button[@Name='Equals']").Click(); Assert.AreEqual("81", GetCalculatorResultText()); }
public static void CloseEdge(WindowsDriver <WindowsElement> edgeSession) { try { edgeSession.Close(); var currentHandle = edgeSession.CurrentWindowHandle; // This should throw if the window is closed successfully // When the Edge window remains open because of multiple tabs are open, attempt to close modal dialog var closeAllButton = edgeSession.FindElementByXPath("//Button[@Name='Close all']"); closeAllButton.Click(); } catch { } }
public void SelectOtherAndSelectUnRead() { ///Button[@Name=\"Other\"] var otherButton = mSessionOutlook.FindElementByXPath("//Button[@Name=\"Other\"]"); mWaitOutlook.Until(x => otherButton.Displayed); otherButton.Click(); // /Button[@Name=\"Sort, arrange or filter messages\"][@ClassName=\"NetUISimpleButton\"] var comboBy = mSessionOutlook.FindElementByXPath("//Button[@Name=\"Sort, arrange or filter messages\"][@ClassName=\"NetUISimpleButton\"]"); mWaitOutlook.Until(x => comboBy.Displayed); comboBy.Click(); var menuItemUnread = mSessionOutlook.FindElementByXPath("//MenuItem[@Name=\"Unread Mail\"][@ClassName=\"NetUITWBtnCheckMenuItem\"]"); mWaitOutlook.Until(x => menuItemUnread.Displayed); menuItemUnread.Click(); }
public void Setup(string appid, string name) { if (session == null) { session = TestHelper.GetSession(appid, name); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); inkCanvas = session.FindElementByClassName("InkCanvas"); recognizeButton = session.FindElementByName("Recognize"); clearButton = session.FindElementByXPath("//Button[@AutomationId=\"clearButton\"]"); numberLabel = session.FindElementByAccessibilityId("numberLabel"); } }
public void SetupBeforeEveryTestMethod() { wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(50)); Assert.IsNotNull(wait); Driver.Manage().Window.Maximize(); jupiter = Driver.FindElementByXPath("//Window[starts-with(@Name,'Jupiter-Pre 5.0')]"); toolBar = Driver.FindElementByName("Ribbon Tabs"); }
public void SuccessTest() { var page = session.PageSource; var xPathQuery = "//Button[@Name=\"Add\"]"; WebDriverWait wait = new WebDriverWait(session, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementExists(By.XPath(xPathQuery))); var btn = session.FindElementByXPath(xPathQuery); var simpleRecords1 = session.FindElementsByXPath("//List[@AutomationId=\"simpleListBox\"]/ListItem/Text"); var customRecords1 = session.FindElementsByXPath("//List[@AutomationId=\"ListBoxLog\"]/ListItem/Text"); btn.Click(); page = session.PageSource; var simpleRecords2 = session.FindElementsByXPath("//List[@AutomationId=\"simpleListBox\"]/ListItem/Text"); var customRecords2 = session.FindElementsByXPath("//List[@AutomationId=\"ListBoxLog\"]/ListItem/Text"); Assert.AreEqual(8, simpleRecords2.Count, "Wrong numer of log records"); }
[TestMethod] public void 輸入帳號密碼_按下登入_預期得到一個彈跳視窗並呈現Hiyao() { WindowsDriver.FindElementByAccessibilityId("Id_TextBox").SendKeys("yao"); WindowsDriver.FindElementByAccessibilityId("Password_TextBox").SendKeys("123456"); WindowsDriver.FindElementByAccessibilityId("Login_Button").Click(); var messageBox = WindowsDriver.FindElementByClassName("#32770"); var title = messageBox.Text; var messageText = messageBox.FindElementByXPath("//Text[@Name='Hi~yao']").Text; Assert.AreEqual("Title", title); Assert.AreEqual("Hi~yao", messageText); WindowsDriver.FindElementByXPath("//Button[@Name='OK']").Click(); }
static void Main(string[] args) { DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); DesiredCapabilities appCapabilities = new DesiredCapabilities(); desiredCapabilities.SetCapability("app", CRMAppId); WindowsDriver <WindowsElement> session, desktopSession; try { session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), desiredCapabilities); } catch (Exception e) { Console.WriteLine(e.Message); } Thread.Sleep(45000); Console.WriteLine("Wait for 45 seconds is over!"); //Creating a desktop session appCapabilities.SetCapability("app", "Root"); desktopSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); //Navigating to target app through desktop session var mainWindow = desktopSession.FindElementByName("CRM Application - Built with Progress® Telerik® UI for WPF"); var mainWindowHandle = mainWindow.GetAttribute("NativeWindowHandle"); mainWindowHandle = (int.Parse(mainWindowHandle)).ToString("x"); // Convert to Hex appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("appTopLevelWindow", mainWindowHandle); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); //Clicking the grid element var cell = session.FindElementByAccessibilityId("CellElement_2_2"); cell.Click(); var mainMenus = session.FindElementByClassName("MainMenuView").FindElementsByClassName("RadRadioButton"); //Clicking on Contact Menu var contactMenu = mainMenus[2]; contactMenu.Click(); Console.WriteLine("Printing menus count " + mainMenus.Count); Console.WriteLine("Printing Grid content " + cell.Text); //Clickig on setting Button. var settingButton = session.FindElementByXPath("//Button[@ClassName=\"RadToggleButton\"]"); settingButton.Click(); Console.WriteLine("Printing menus count " + mainMenus.Count); }
protected void DeletePreviouslyCreatedAlarmEntry(string alarmName) { while (true) { try { var alarmEntry = session.FindElementByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]"); session.Mouse.ContextClick(alarmEntry.Coordinates); session.FindElementByName("Delete").Click(); } catch { break; } } }
public void Test_WinFormsApp_ValidData() { //var textBoxFirstNum = driver.FindElementByAccessibilityId("textBoxFirstNum"); var textBoxFirstNum = driver.FindElementByXPath("//Edit[@AutomationId='textBoxFirstNum']"); textBoxFirstNum.SendKeys("5"); var textBoxSecondNum = driver.FindElementByAccessibilityId("textBoxSecondNum"); textBoxSecondNum.SendKeys("7"); var buttonCalc = driver.FindElementByAccessibilityId("buttonCalc"); buttonCalc.Click(); var textBoxSum = driver.FindElementByAccessibilityId("textBoxSum"); Assert.AreEqual("12", textBoxSum.Text); }
public void Setup(string appid) { if (session == null) { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", appid); appCapabilities.SetCapability("deviceName", "WindowsPC"); session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5); inkCanvas = session.FindElementByClassName("InkCanvas"); recognizeButton = session.FindElementByName("Recognize"); clearButton = session.FindElementByXPath("//Button[@AutomationId=\"clearButton\"]"); numberLabel = session.FindElementByAccessibilityId("numberLabel"); } }
public static void TestBug10763() // Preference: "Use wheel for zoom" is not kept { Driver.FindElementByName("Preferences").Click(); var preferences = jupiter.FindElementByName("Preferences"); preferences.FindElementByName("Mouse").Click(); preferences.FindElementByName("MyPreset1").Click(); var useWheel = preferences.FindElementByAccessibilityId("2037"); if (!useWheel.Selected) { useWheel.Click(); preferences.FindElementByName("OK").Click(); Driver.Close(); Thread.Sleep(4000); AppiumOptions appOptions = new AppiumOptions(); Assert.IsNotNull(appOptions); appOptions.AddAdditionalCapability("app", @"C:\Program Files\TechnoStar\Jupiter-Post_4.1.2\PCAD_main.exe"); Driver = new WindowsDriver <WindowsElement>( new Uri("http://127.0.0.1:4723"), appOptions, TimeSpan.FromMinutes(5) ); Assert.IsNotNull(Driver); Assert.IsNotNull(Driver.SessionId); wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(50)); Assert.IsNotNull(wait); Driver.Manage().Window.Maximize(); jupiter = Driver.FindElementByXPath("//Window[starts-with(@Name,'Jupiter-Post 4.1.2')]"); toolBar = Driver.FindElementByName("Ribbon Tabs"); } Driver.FindElementByName("Preferences").Click(); preferences = jupiter.FindElementByName("Preferences"); preferences.FindElementByName("Mouse").Click(); preferences.FindElementByName("MyPreset1").Click(); useWheel = preferences.FindElementByAccessibilityId("2037"); Assert.IsTrue(useWheel.Selected); Thread.Sleep(2000); }
public static WindowsDriver <WindowsElement> abrirFenix() { if (session == null) { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", EXECUTAVEL_FENIX); try { session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); } catch (Exception e) { string message = e.Message; } Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); var currentWindowHandle = session.CurrentWindowHandle; Thread.Sleep(TimeSpan.FromSeconds(3)); var allWindowHandles = session.WindowHandles; session.SwitchTo().Window(allWindowHandles[0]); try { WindowsElement element = session.FindElementByName("Novidades das versões"); //element.FindElementByXPath(WindowsObjects.JanelaPrincipal.ICONE_FECHAR_APLICACAO).Click(); session.FindElementByXPath(WindowsObjects.JanelaPrincipal.ICONE_FECHAR_APLICACAO).Click(); } catch (Exception e) { string message = e.Message; } } return(session); }
public static void TearDown() { ReturnToMainPage(); SwitchToAlarmTab(); // Delete all created alarms while (true) { try { var alarmEntry = AlarmClockSession.FindElementByXPath(string.Format("//ListItem[starts-with(@Name, \"{0}\")]", NewAlarmName)); AlarmClockSession.Mouse.ContextClick(alarmEntry.Coordinates); AlarmClockSession.FindElementByName("Delete").Click(); } catch { break; } } AlarmClockSession.Quit(); AlarmClockSession = null; }
public static void TearDown() { // Cleanup RemoteTouchScreen object if initialized touchScreen = null; // Close the application and delete the session if (session != null) { try { session.Close(); var currentHandle = session.CurrentWindowHandle; // This should throw if the window is closed successfully // When the Edge window remains open because of multiple tabs are open, attempt to close modal dialog var closeAllButton = session.FindElementByXPath("//Button[@Name='Close all']"); closeAllButton.Click(); } catch { } session.Quit(); session = null; } }