public static TagName ( string tagNameToFind ) : |
||
tagNameToFind | string | The tag name to find. |
return |
public bool selectByOptionText(By locator, string value, string locatorName) { bool flag = false; try { WebElement ListBox = driver.FindElement(locator); IReadOnlyCollection <WebElement> options = ListBox.FindElements(By.TagName("option")); foreach (var option in options) { string opt = option.Text.Trim(); if (opt.ToLower().Equals(value.ToLower().Trim())) { option.Click(); flag = true; break; } } } catch (Exception e) { System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg; ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(Path.Combine(projectLoc, TestContext.CurrentContext.Test.Name + "-" + DateTime.Now.ToString("dd-M-yyyy", CultureInfo.InvariantCulture) + "." + format), format); throw new Exception("Option with value attribute " + value + " is Not Select from the DropDown " + locatorName + " " + e.Message); } return(flag); }
/// <summary> /// Gets a mechanism to find elements by their tag name. /// </summary> /// <param name="tagNameToFind">The tag name to find.</param> /// <returns>A <see cref="OpenQA.Selenium.By"/> object the driver can use to find the elements.</returns> public static new SeleniumBy TagName(string tagNameToFind) => SeleniumBy.TagName(tagNameToFind);
public void ClicksASurroundingStrongTag() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("ClickTest_testClicksASurroundingStrongTag.html"); driver.FindElement(By.TagName("a")).Click(); WaitFor(() => { return(driver.Title == "XHTML Test Page"); }, "Browser title was not 'XHTML Test Page'"); }
public void ShouldBeAbleToSwitchToFrameWithNameContainingDot() { driver.Url = framesetPage; driver.SwitchTo().Frame("sixth.iframe1"); Assert.IsTrue(driver.FindElement(By.TagName("body")).Text.Contains("Page number 3")); }
public void CanClickOnAnElementEnclosedInALink() { driver.FindElement(By.Id("link-with-enclosed-span")).FindElement(By.TagName("span")).Click(); WaitFor(() => { return(driver.Title == "XHTML Test Page"); }, "Browser title was not 'XHTML Test Page'"); Assert.AreEqual("XHTML Test Page", driver.Title); }
public void ShouldBeAbleToSwitchToAFrameByItsName() { driver.Url = framesetPage; driver.SwitchTo().Frame("fourth"); Assert.AreEqual("child1", driver.FindElement(By.TagName("frame")).GetAttribute("name")); }
public void ShouldNotBeAbleToFindAnElementOnABlankPage() { driver.Url = "about:blank"; Assert.Throws <NoSuchElementException>(() => driver.FindElement(By.TagName("a"))); }
public void FindingASingleElementByTagNameWithSpaceShouldThrow() { driver.Url = formsPage; Assert.Throws <NoSuchElementException>(() => driver.FindElement(By.TagName("nonexistent button"))); }
public void FindingMultipleElementsByEmptyTagNameShouldThrow() { driver.Url = formsPage; Assert.Throws <InvalidSelectorException>(() => driver.FindElements(By.TagName("")));; }
public void ShouldNotBeAbleToLocateByTagNameASingleElementThatDoesNotExist() { driver.Url = formsPage; Assert.Throws <NoSuchElementException>(() => driver.FindElement(By.TagName("nonExistentButton"))); }