ReadOnlyCollection <WindowsElement> QueryWindows(WinQuery query, bool findFirst = false) { var resultByAccessibilityId = _session.FindElementsByAccessibilityId(query.Marked); ReadOnlyCollection <WindowsElement> resultByName = null; if (!findFirst || resultByAccessibilityId.Count == 0) { resultByName = _session.FindElementsByName(query.Marked); } IEnumerable <WindowsElement> result = resultByAccessibilityId; if (resultByName != null) { result = result.Concat(resultByName); } // TODO hartez 2017/10/30 09:47:44 Should this be == "*" || == "TextBox"? // what about other controls where we might be looking by content? TextBlock? if (query.ControlType == "*") { IEnumerable <WindowsElement> textBoxesByContent = _session.FindElementsByClassName("TextBox").Where(e => e.Text == query.Marked); result = result.Concat(textBoxesByContent); } return(FilterControlType(result, query.ControlType)); }
ReadOnlyCollection <WindowsElement> QueryWindows(WinQuery query) { var resultByName = _session.FindElementsByName(query.Marked); var resultByAccessibilityId = _session.FindElementsByAccessibilityId(query.Marked); var result = resultByName .Concat(resultByAccessibilityId); if (query.ControlType == "*") { var textBoxesByContent = _session.FindElementsByClassName("TextBox").Where(e => e.Text == query.Marked); result = result.Concat(textBoxesByContent); } return(FilterControlType(result, query.ControlType)); }
private async Task <bool> ClickNoOnPopUpAsync(WindowsDriver <WindowsElement> session) { await Task.Delay(TimeSpan.FromSeconds(1)); // Allow extra time for popup to be displayed var popups = session.FindElementsByAccessibilityId("Popup Window"); if (popups.Count == 1) { var no = popups[0].FindElementsByName("No"); if (no.Count == 1) { no[0].Click(); return(true); } } return(false); }
public void Test_07_FindElement() { WindowsElement element = session.FindElementByAccessibilityId("mainframe.ChildFrame00.form.Button00"); Assert.IsNotNull(element); ReadOnlyCollection <WindowsElement> elements = session.FindElementsByAccessibilityId("mainframe.ChildFrame00.form.Button00"); Assert.IsNotNull(elements); WindowsElement nexaComboDrop00 = session.FindElementByAccessibilityId("mainframe.ChildFrame00.form.Div00.form.Combo00.dropbutton"); Assert.IsNotNull(nexaComboDrop00); WindowsElement nexaRadioItem1 = session.FindElementByAccessibilityId("mainframe.ChildFrame00.form.Radio00.radioitem1"); Assert.IsNotNull(nexaRadioItem1); }
public override IEnumerable <WindowsElement> FindAllElements(WindowsDriver <WindowsElement> searchContext) { return(searchContext.FindElementsByAccessibilityId(Value)); }
public void Test1() { //var header = _driver.FindElementByAccessibilityId(("ButtonAddNewSapSystem")); //var name = header.GetAttribute("Name"); //TestContext.Out.WriteLine($"Profile: {name}"); //Assert.AreEqual(name, "SAP-System erstellen", "Wrong profile name"); //var sysButton = _driver.FindElement(By.XPath("//Text[@AutomationId='SID' and @Name='MT7']/..")); var sysButton = _driver.FindElement(By.XPath("//Text[@AutomationId='SID' and @Name='MT7']/parent::*")); //sysButton.Click(); var description = sysButton.FindElement(By.XPath("//Text[@AutomationId='SystemDescription']")) .GetAttribute("Name"); var helpButton = sysButton.FindElement(By.XPath("//Button[@AutomationId='EditSapSystemButton']")); var removeSapSystemButton = sysButton.FindElement(By.XPath("//Button[@AutomationId='RemoveSapSystemButton']")); //var t1 = _driver // .FindElementsByAccessibilityId("SID"); //var t2 = t1.Single(e => e.GetAttribute("Name") == "MT7"); var text = _driver.FindElement(By.XPath("//Text[@AutomationId='SID' and @Name='MT7']")); //var t3 = text.FindElement(By.XPath("./..")); //var sysButton = _driver // .FindElementsByAccessibilityId("SID") // .Single(e => e.GetAttribute("Name") == "MT7") // .FindElement(By.XPath("./..")); var systems = _driver.FindElements(By.XPath("//Text[@AutomationId='SID']")); var sids = systems.Select(e => e.GetAttribute("Name")).ToList(); var systemButtons = _driver.FindElementsByAccessibilityId(("SapSystemButton")); foreach (var system in systemButtons) { //var button = system.FindElement(By.XPath("//Text[@AutomationId='SID']/..")); // var test = system.FindElement(By.XPath("//Text[@AutomationId='SID']")).GetAttribute("Name"); // TestContext.Out.WriteLine($"System: {test}"); } //var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5)); //wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException)); //var visible = wait.Until(driver => driver.FindElement(By.Id("header")).Displayed); //Assert.IsTrue(visible, "Header not visible"); //var exist = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.Id("header"))); ////new WebDriverWait(_driver, TimeSpan.FromSeconds(5)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.Id("header"))); //var header1 = wait.Until(c => c.FindElement(By.Id("header"))); //Assert.AreEqual(header1.Text, "Default", "Wrong profile name"); //var header2 = _driver.Wait().ForElement(By.Id("header")).ToExist(); //Assert.AreEqual(header2.Text, "Default", "Wrong profile name"); //var userInput = _driver.FindElement(By.Id("userInput")); //userInput.SendKeys("mobentw"); //var user = userInput.GetAttribute("value"); //Assert.AreEqual(user, "mobentw", "Wrong user"); //TestContext.Out.WriteLine($"User: {user}"); //var passwordInput = _driver.FindElement(By.Id("passwordInput")); //passwordInput.SendKeys("sapmobis"); //var password = passwordInput.GetAttribute("value"); //Assert.AreEqual(password, "sapmobis", "Wrong password"); //TestContext.Out.WriteLine($"Password: {password}"); //var loginApplicationInput = _driver.FindElement(By.Id("loginApplicationInput")); //loginApplicationInput.SendKeys("QS1"); //var application = loginApplicationInput.GetAttribute("value"); //Assert.AreEqual(application, "QS1", "Wrong application"); //TestContext.Out.WriteLine($"Application: {application}"); //var profileButton = _driver.FindElement(By.Id("header")); ////profileButton.Click(); //var settingsButton = _driver.FindElement(By.Id("settingsButton")); //settingsButton.Click(); //var cancelButton = _driver.FindElement(By.Id("cancelButton")); //_driver.ExecuteJavaScript("arguments[0].scrollIntoView(true);", cancelButton); //Thread.Sleep(1000); //cancelButton.Click(); //Assert.Pass(); }
/// <summary> /// Wait for a WindowsElement to be found by AccessibilityId. /// </summary> /// <param name="windowsDriver">This WindowsDriver.</param> /// <param name="accessibilityId">The AccessibilityId of the WindowsElement.</param> /// <param name="timeout">The maximum amount of time to wait.</param> /// <param name="index">The expected index among the WindowsElements matching the AccessibilityId.</param> /// <returns>The WindowsElement matching the AccessibilityId, otherwise <c>null</c>.</returns> public static WindowsElement FindElementByAccessibilityId(this WindowsDriver <WindowsElement> windowsDriver, string accessibilityId, TimeSpan timeout, int index) { Func <WindowsElement> searchMethod = () => windowsDriver.FindElementsByAccessibilityId(accessibilityId).ToList().ElementAtOrDefault(index); return(FindElement(windowsDriver, searchMethod, timeout)); }
public int getRejectAllBtnCt() { return(driver.FindElementsByAccessibilityId("btRejectAll").Count()); }