public FindElement ( ISearchContext context ) : IWebElement | ||
context | ISearchContext | An |
return | IWebElement |
/// <summary> /// Finds the first element in the page that matches the <see cref="By"/> object /// </summary> /// <param name="by">By mechanism to find the object</param> /// <returns>IWebElement object so that you can interact with that object</returns> /// <example> /// <code> /// IWebDriver driver = new InternetExplorerDriver(); /// IWebElement elem = driver.FindElement(By.Name("q")); /// </code> /// </example> public IWebElement FindElement(By by) { if (by == null) { throw new ArgumentNullException("by", "by cannot be null"); } return(by.FindElement(this)); }
/// <summary> /// Finds the first <see cref="IWebElement"/> using the given method. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns>The first matching <see cref="IWebElement"/> on the current context.</returns> /// <exception cref="NoSuchElementException">If no element matches the criteria.</exception> public virtual IWebElement FindElement(By by) { if (by == null) { throw new ArgumentNullException(nameof(@by), "by cannot be null"); } return(by.FindElement(this)); }
// TODO (jimevan): This test is disabled in the Java implementation unit tests. // Is the functionality not implemented? public void ShouldUseXPathToFindByNameIfDriverDoesNotImplementFindsByName() { DynamicMock driver = new DynamicMock(typeof(IOnlyXPath)); driver.Expect("FindElementByXPath", new object[] { "//*[@name='cheese']" }); By by = By.Name("cheese"); by.FindElement(driver.MockInstance as IOnlyXPath); }
public void ShouldUseFindsByNameToLocateElementsByName() { DynamicMock driver = new DynamicMock(typeof(IAllDriver)); driver.Expect("FindElementByName", new object[] { "cheese" }); By by = By.Name("cheese"); by.FindElement(driver.MockInstance as IAllDriver); }
// TODO (jimevan): This test is disabled in the Java implementation unit tests. // Is the functionality not implemented? public void ShouldUseXPathToFindByNameIfDriverDoesNotImplementFindsByName() { var mockDriver = mocks.NewMock <IOnlyXPath>(); var mockElement = mocks.NewMock <IWebElement>(); Expect.Once.On(mockDriver).Method("FindElementByXPath").With("//*[@name='cheese']").Will(Return.Value(mockElement)); By by = By.Name("cheese"); by.FindElement(mockDriver); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void ShouldUseFindsByNameToLocateElementsByName() { var mockDriver = mocks.NewMock <IAllDriver>(); var mockElement = mocks.NewMock <IWebElement>(); Expect.Once.On(mockDriver).Method("FindElementByName").With("cheese").Will(Return.Value(mockElement)); By by = By.Name("cheese"); by.FindElement(mockDriver); mocks.VerifyAllExpectationsHaveBeenMet(); }
// TODO (jimevan): This test is disabled in the Java implementation unit tests. // Is the functionality not implemented?* public void ShouldUseXPathToFindByNameIfDriverDoesNotImplementFindsByName() { var mockDriver = new Mock <IOnlyXPath>(); var mockElement = new Mock <IWebElement>(); mockDriver.Setup(_ => _.FindElementByXPath(It.Is <string>(x => x == "//*[@name='cheese']"))).Returns(mockElement.Object); By by = By.Name("cheese"); var element = by.FindElement(mockDriver.Object); Assert.AreEqual(mockElement.Object, element); }
// TODO (jimevan): This test is disabled in the Java implementation unit tests. // Is the functionality not implemented?* public void ShouldUseXPathToFindByNameIfDriverDoesNotImplementFindsByName() { var mockDriver = mocks.CreateMock <IOnlyXPath>(); var mockElement = mocks.CreateMock <IWebElement>(); mockDriver.Expects.One.Method(_ => _.FindElementByXPath("//*[@name='cheese']")).WillReturn(mockElement.MockObject); By by = By.Name("cheese"); by.FindElement(mockDriver.MockObject); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void ShouldUseFindsByNameToLocateElementsByName() { var mockDriver = mocks.CreateMock <IAllDriver>(); var mockElement = mocks.CreateMock <IWebElement>(); mockDriver.Expects.One.Method(_ => _.FindElementByName(null)).With("cheese").Will(Return.Value(mockElement.MockObject)); By by = By.Name("cheese"); by.FindElement(mockDriver.MockObject); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void ShouldUseFindsByNameToLocateElementsByName() { var mockDriver = new Mock <IAllDriver>(); var mockElement = new Mock <IWebElement>(); mockDriver.Setup(_ => _.FindElementByName(It.Is <string>(x => x == "cheese"))).Returns(mockElement.Object); By by = By.Name("cheese"); var element = by.FindElement(mockDriver.Object); Assert.AreEqual(mockElement.Object, element); mockDriver.Verify(x => x.FindElementByName("cheese"), Times.Once); }
public IWebElement FindElement(By by) { return by.FindElement(this); }
/// <summary> /// Verifica se o elemento não está presente na página. /// </summary> /// <param name="by">O seletor do elemento.</param> /// <returns>True se está presente, false no contrário.</returns> public static void AssertIsElementNotPresent(By by) { StepHelper.Attempt(() => { return !IsElementPresent(by); }); ExceptionAssert.IsThrowing(typeof(NoSuchElementException), () => { by.FindElement(Driver); }); }
public IWebElement FindElement(By by) { return by.FindElement(new WebElementFinder(_browser.Page.HtmlNode(), Navigate())); }
public IWebElement FindElement(By mechanism) { return mechanism.FindElement(new ElementFinderContext(_xElement)); }
public IWebElement FindElement(By mechanism) { return mechanism.FindElement(new ElementFinderContext(currentNode, webBrowser)); }
public IWebElement FindElement(By by) { ISearchContext ctx = CreateSearchContext(_my); return by.FindElement(ctx); }
/// <summary> /// Verifica se o elemento está presente na página. /// </summary> /// <param name="by">O seletor do elemento.</param> /// <returns>True se está presente, false no contrário.</returns> public static void AssertIsElementPresent(By by) { StepHelper.Attempt(() => { return IsElementPresent(by); }); Assert.IsNotNull(by.FindElement(Driver)); }