public void FindElementTwoByEmptyChild() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); Mock <IAllElement> elem1 = new Mock <IAllElement>(); Mock <IAllElement> elem2 = new Mock <IAllElement>(); Mock <IAllElement> elem5 = new Mock <IAllElement>(); var elems = new List <IWebElement>().AsReadOnly(); var elems12 = new List <IWebElement>() { elem1.Object, elem2.Object }.AsReadOnly(); var elems5 = new List <IWebElement>() { elem5.Object }.AsReadOnly(); driver.Setup(_ => _.FindElements(by.Mechanism, by.Criteria)).Returns(elems12); elem1.Setup(_ => _.FindElements(by2)).Returns(elems); elem2.Setup(_ => _.FindElements(by2)).Returns(elems5); ByChained byChained = new ByChained(by, by2); Assert.That(byChained.FindElement(driver.Object), Is.EqualTo(elem5.Object)); driver.Verify(_ => _.FindElements(by.Mechanism, by.Criteria), Times.Once); elem1.Verify(_ => _.FindElements(by2), Times.Once); elem2.Verify(_ => _.FindElements(by2), Times.Once); }
public void FindElementTwoByEmptyChild() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); Mock <IAllElement> elem1 = new Mock <IAllElement>(); Mock <IAllElement> elem2 = new Mock <IAllElement>(); Mock <IAllElement> elem5 = new Mock <IAllElement>(); var elems = new List <IWebElement>().AsReadOnly(); var elems12 = new List <IWebElement>() { elem1.Object, elem2.Object }.AsReadOnly(); var elems5 = new List <IWebElement>() { elem5.Object }.AsReadOnly(); driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12); elem1.Setup(_ => _.FindElements(It.Is <By>(x => x.Equals(By.Name("photo"))))).Returns(elems); elem2.Setup(_ => _.FindElements(It.Is <By>(x => x.Equals(By.Name("photo"))))).Returns(elems5); ByChained by = new ByChained(By.Name("cheese"), By.Name("photo")); Assert.That(by.FindElement(driver.Object), Is.EqualTo(elem5.Object)); driver.Verify(_ => _.FindElementsByName("cheese"), Times.Once); elem1.Verify(_ => _.FindElements(By.Name("photo")), Times.Once); elem2.Verify(_ => _.FindElements(By.Name("photo")), Times.Once); }
public void FindElementZeroBy() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); ByChained byChained = new ByChained(); Assert.Throws <NoSuchElementException>(() => byChained.FindElement(driver.Object)); }
public void FindElement_TwoBys_ShouldReturnOne() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("classes"), By.CssSelector(".one")); Assert.AreEqual("Find me", by.FindElement(driver).Text); }
public void FindElement_ShouldReturnOne() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("div1")); Assert.IsTrue(by.FindElement(driver).Displayed); }
public void FindElement_TwoBys_ShouldThrow() { driver.Url = nestedPage; driver.Navigate(); try { var by = new ByChained(By.Name("classes"), By.CssSelector(".NotFound")); by.FindElement(driver); Assert.Fail("Expected NotFoundException"); } catch (NotFoundException) { Assert.Pass(); } }
public void FindElementNotFound_ShouldThrow() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("NotFoundAtAll")); try { by.FindElement(driver); Assert.Fail("Expected NotFoundExcepotion"); } catch (NotFoundException) { Assert.Pass(); } }
public void FindElementOneBy() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); Mock <IAllElement> elem1 = new Mock <IAllElement>(); Mock <IAllElement> elem2 = new Mock <IAllElement>(); var elems12 = new List <IWebElement>() { elem1.Object, elem2.Object }.AsReadOnly(); driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12); ByChained by = new ByChained(By.Name("cheese")); Assert.AreEqual(by.FindElement(driver.Object), elem1.Object); driver.Verify(_ => _.FindElementsByName("cheese"), Times.Once); }
public void FindElementOneByEmpty() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); var elems = new List <IWebElement>().AsReadOnly(); driver.Setup(_ => _.FindElements(by.Mechanism, by.Criteria)).Returns(elems); ByChained byChained = new ByChained(by); try { byChained.FindElement(driver.Object); Assert.Fail("Expected NoSuchElementException!"); } catch (NoSuchElementException) { driver.Verify(_ => _.FindElements(by.Mechanism, by.Criteria), Times.Once); Assert.Pass(); } }
public void FindElementOneByEmpty() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); var elems = new List <IWebElement>().AsReadOnly(); driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems); ByChained by = new ByChained(By.Name("cheese")); try { by.FindElement(driver.Object); Assert.Fail("Expected NoSuchElementException!"); } catch (NoSuchElementException) { driver.Verify(_ => _.FindElementsByName("cheese"), Times.Once); Assert.Pass(); } }