public void FindElement_ShouldThrowExceptionIfNoElementsFound() { _javaScriptExecutorMock .Setup(javaScriptExecutor => javaScriptExecutor.ExecuteScript(It.IsAny <string>(), It.IsAny <IWebElement>(), It.IsAny <bool>())) .Returns(new ReadOnlyCollection <IWebElement>(new List <IWebElement>())); var byVisibleText = new ByVisible(true); Assert.Throws <NoSuchElementException>(() => byVisibleText.FindElement(_webElementMock.Object)); }
public void FindElement_ShouldReturnFirstFoundElement() { var resultWebElementMock1 = new Mock <IWebElement>(); var resultWebElementMock2 = new Mock <IWebElement>(); var resultWebElementMock3 = new Mock <IWebElement>(); _javaScriptExecutorMock .Setup(javaScriptExecutor => javaScriptExecutor.ExecuteScript(It.IsAny <string>(), It.IsAny <IWebElement>(), It.IsAny <bool>())) .Returns(new ReadOnlyCollection <IWebElement>(new List <IWebElement> { resultWebElementMock1.Object, resultWebElementMock2.Object, resultWebElementMock3.Object })); var byVisibleText = new ByVisible(true); var resultElement = byVisibleText.FindElement(_webElementMock.Object); Assert.AreSame(resultWebElementMock1.Object, resultElement); }