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 FindElementTwoByEmptyChild() { MockFactory mocks = new MockFactory(); Mock <IAllDriver> driver = mocks.CreateMock <IAllDriver>(); Mock <IAllElement> elem1 = mocks.CreateMock <IAllElement>(); Mock <IAllElement> elem2 = mocks.CreateMock <IAllElement>(); Mock <IAllElement> elem5 = mocks.CreateMock <IAllElement>(); var elems = new List <IWebElement>().AsReadOnly(); var elems12 = new List <IWebElement>() { elem1.MockObject, elem2.MockObject }.AsReadOnly(); var elems5 = new List <IWebElement>() { elem5.MockObject }.AsReadOnly(); driver.Expects.One.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems12); elem1.Expects.One.Method(_ => _.FindElements(null)).With(By.Name("photo")).WillReturn(elems); elem2.Expects.One.Method(_ => _.FindElements(null)).With(By.Name("photo")).WillReturn(elems5); ByChained by = new ByChained(By.Name("cheese"), By.Name("photo")); Assert.That(by.FindElement(driver.MockObject), Is.EqualTo(elem5.MockObject)); mocks.VerifyAllExpectationsHaveBeenMet(); }
private static List <By> CreateLocatorList(MemberInfo member) { var useSequenceAttributes = Attribute.GetCustomAttributes(member, typeof(FindsBySequenceAttribute), true); bool useSequence = useSequenceAttributes.Length > 0; List <By> bys = new List <By>(); var attributes = Attribute.GetCustomAttributes(member, typeof(FindsByAttribute), true); if (attributes.Length > 0) { Array.Sort(attributes); foreach (var attribute in attributes) { var castedAttribute = (FindsByAttribute)attribute; if (castedAttribute.Using == null) { castedAttribute.Using = member.Name; } bys.Add(castedAttribute.Finder); } if (useSequence) { ByChained chained = new ByChained(bys.ToArray()); bys.Clear(); bys.Add(chained); } } return(bys); }
public void FindElementTwoByEmptyChild() { Mockery mocks = new Mockery(); IAllDriver driver = mocks.NewMock <IAllDriver>(); IAllElement elem1 = mocks.NewMock <IAllElement>(); IAllElement elem2 = mocks.NewMock <IAllElement>(); IAllElement elem5 = mocks.NewMock <IAllElement>(); var elems = new List <IWebElement>().AsReadOnly(); var elems12 = new List <IWebElement>() { elem1, elem2 }.AsReadOnly(); var elems5 = new List <IWebElement>() { elem5 }.AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12)); Expect.Once.On(elem1).Method("FindElements").With(By.Name("photo")).Will(Return.Value(elems)); Expect.Once.On(elem2).Method("FindElements").With(By.Name("photo")).Will(Return.Value(elems5)); ByChained by = new ByChained(By.Name("cheese"), By.Name("photo")); Assert.That(by.FindElement(driver), Is.EqualTo(elem5)); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void FindElementsZeroBy() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); ByChained by = new ByChained(); Assert.That(by.FindElements(driver.Object), Is.EqualTo(new List <IWebElement>().AsReadOnly())); }
public void FindElementZeroBy() { Mock <IAllDriver> driver = new Mock <IAllDriver>(); ByChained by = new ByChained(); Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.Object)); }
public void FindElementZeroBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock<IAllDriver>(); ByChained by = new ByChained(); by.FindElement(driver); }
public void FindElement_ShouldReturnOne() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("div1")); Assert.IsTrue(by.FindElement(driver).Displayed); }
public void FindElementZeroBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock<IAllDriver>(); ByChained by = new ByChained(); Assert.Throws<NoSuchElementException>(() => by.FindElement(driver)); }
public void FindElements_ShouldReturnMultiple() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("div1")); Assert.AreEqual(4, by.FindElements(driver).Count); }
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 FindElementsZeroBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock<IAllDriver>(); ByChained by = new ByChained(); Assert.That(by.FindElements(driver), Is.EqualTo(new List<IWebElement>().AsReadOnly())); }
public void FindElements_TwoBys_ShouldReturnZero() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("classes"), By.CssSelector(".NotFound")); Assert.AreEqual(0, by.FindElements(driver).Count); }
public void FindElementsNotFound_ShouldBeZero() { driver.Url = nestedPage; driver.Navigate(); var by = new ByChained(By.Name("NotFoundAtAll")); Assert.AreEqual(0, by.FindElements(driver).Count); }
public void FindElementZeroBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock <IAllDriver>(); ByChained by = new ByChained(); Assert.Throws <NoSuchElementException>(() => by.FindElement(driver)); }
public void FindElementZeroBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock <IAllDriver>(); ByChained by = new ByChained(); by.FindElement(driver); }
public void FindElementZeroBy() { MockFactory mock = new MockFactory(); Mock <IAllDriver> driver = mock.CreateMock <IAllDriver>(); ByChained by = new ByChained(); Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.MockObject)); }
public void FindElementsOneByEmpty() { 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")); Assert.That(by.FindElements(driver.Object), Is.EqualTo(elems)); }
public void FindElementsOneByEmpty() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock <IAllDriver>(); var elems = new List <IWebElement>().AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems)); ByChained by = new ByChained(By.Name("cheese")); Assert.That(by.FindElements(driver), Is.EqualTo(elems)); }
public void FindElementsOneByEmpty() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock<IAllDriver>(); var elems = new List<IWebElement>().AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems)); ByChained by = new ByChained(By.Name("cheese")); Assert.That(by.FindElements(driver), Is.EqualTo(elems)); }
public void FindElementsOneByEmpty() { MockFactory mock = new MockFactory(); Mock <IAllDriver> driver = mock.CreateMock <IAllDriver>(); var elems = new List <IWebElement>().AsReadOnly(); driver.Expects.One.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems); ByChained by = new ByChained(By.Name("cheese")); Assert.That(by.FindElements(driver.MockObject), Is.EqualTo(elems)); }
/// <summary> /// Creates a list of <see cref="By"/> locators based on the attributes of this member. /// </summary> /// <param name="member">The <see cref="MemberInfo"/> containing information about /// the member of the Page Object class.</param> /// <returns>A list of <see cref="By"/> locators based on the attributes of this member.</returns> protected static ReadOnlyCollection <By> CreateLocatorList(MemberInfo member) { if (member == null) { throw new ArgumentNullException("member", "memeber cannot be null"); } var useSequenceAttributes = Attribute.GetCustomAttributes(member, typeof(FindsBySequenceAttribute), true); bool useSequence = useSequenceAttributes.Length > 0; var useFindAllAttributes = Attribute.GetCustomAttributes(member, typeof(FindsByAllAttribute), true); bool useAll = useFindAllAttributes.Length > 0; if (useSequence && useAll) { throw new ArgumentException("Cannot specify FindsBySequence and FindsByAll on the same member"); } List <By> bys = new List <By>(); var attributes = Attribute.GetCustomAttributes(member, typeof(FindsByAttribute), true); if (attributes.Length > 0) { Array.Sort(attributes); foreach (var attribute in attributes) { var castedAttribute = (FindsByAttribute)attribute; if (castedAttribute.Using == null) { castedAttribute.Using = member.Name; } bys.Add(castedAttribute.Finder); } if (useSequence) { ByChained chained = new ByChained(bys.ToArray()); bys.Clear(); bys.Add(chained); } if (useAll) { ByAll all = new ByAll(bys.ToArray()); bys.Clear(); bys.Add(all); } } return(bys.AsReadOnly()); }
public void FindElementsOneBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock<IAllDriver>(); IAllElement elem1 = mock.NewMock<IAllElement>(); IAllElement elem2 = mock.NewMock<IAllElement>(); var elems12 = new List<IWebElement>() { elem1, elem2 }.AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12)); ByChained by = new ByChained(By.Name("cheese")); Assert.AreEqual(by.FindElements(driver), elems12); mock.VerifyAllExpectationsHaveBeenMet(); }
protected static ReadOnlyCollection <By> CreateLocatorList(MemberInfo member) { if (member == null) { throw new ArgumentNullException("member", "memeber cannot be null"); } Attribute[] customAttributes = Attribute.GetCustomAttributes(member, typeof(FindsBySequenceAttribute), true); bool flag = customAttributes.Length > 0; Attribute[] customAttributes2 = Attribute.GetCustomAttributes(member, typeof(FindsByAllAttribute), true); bool flag2 = customAttributes2.Length > 0; if (flag && flag2) { throw new ArgumentException("Cannot specify FindsBySequence and FindsByAll on the same member"); } List <By> list = new List <By>(); Attribute[] customAttributes3 = Attribute.GetCustomAttributes(member, typeof(FindsByAttribute), true); if (customAttributes3.Length > 0) { Array.Sort <Attribute>(customAttributes3); Attribute[] array = customAttributes3; for (int i = 0; i < array.Length; i++) { Attribute attribute = array[i]; FindsByAttribute findsByAttribute = (FindsByAttribute)attribute; if (findsByAttribute.Using == null) { findsByAttribute.Using = member.Name; } list.Add(findsByAttribute.Finder); } if (flag) { ByChained item = new ByChained(list.ToArray()); list.Clear(); list.Add(item); } if (flag2) { ByAll item2 = new ByAll(list.ToArray()); list.Clear(); list.Add(item2); } } return(list.AsReadOnly()); }
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 FindElementsOneBy() { 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.FindElements(driver.Object), elems12); driver.Verify(_ => _.FindElementsByName("cheese"), Times.Once); }
public void FindElementsOneBy() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock <IAllDriver>(); IAllElement elem1 = mock.NewMock <IAllElement>(); IAllElement elem2 = mock.NewMock <IAllElement>(); var elems12 = new List <IWebElement>() { elem1, elem2 }.AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12)); ByChained by = new ByChained(By.Name("cheese")); Assert.AreEqual(by.FindElements(driver), elems12); mock.VerifyAllExpectationsHaveBeenMet(); }
private static List<By> GetListOfComplexBys(bool useSequence, bool useAll, List<By> bys) { if (useSequence) { ByChained chained = new ByChained(bys.ToArray()); bys.Clear(); bys.Add(chained); } if (useAll) { ByAll all = new ByAll(bys.ToArray()); bys.Clear(); bys.Add(all); } return bys; }
public void FindElementsOneBy() { MockFactory mock = new MockFactory(); Mock <IAllDriver> driver = mock.CreateMock <IAllDriver>(); Mock <IAllElement> elem1 = mock.CreateMock <IAllElement>(); Mock <IAllElement> elem2 = mock.CreateMock <IAllElement>(); var elems12 = new List <IWebElement>() { elem1.MockObject, elem2.MockObject }.AsReadOnly(); driver.Expects.One.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems12); ByChained by = new ByChained(By.Name("cheese")); Assert.AreEqual(by.FindElements(driver.MockObject), elems12); mock.VerifyAllExpectationsHaveBeenMet(); }
public void FindElementOneByEmpty() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock<IAllDriver>(); var elems = new List<IWebElement>().AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems)); ByChained by = new ByChained(By.Name("cheese")); try { by.FindElement(driver); Assert.Fail("Expected NoSuchElementException!"); } catch (NoSuchElementException) { mock.VerifyAllExpectationsHaveBeenMet(); 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(); } }
public void FindElementOneByEmpty() { MockFactory mock = new MockFactory(); Mock <IAllDriver> driver = mock.CreateMock <IAllDriver>(); var elems = new List <IWebElement>().AsReadOnly(); driver.Expects.One.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems); ByChained by = new ByChained(By.Name("cheese")); try { by.FindElement(driver.MockObject); Assert.Fail("Expected NoSuchElementException!"); } catch (NoSuchElementException) { mock.VerifyAllExpectationsHaveBeenMet(); Assert.Pass(); } }
public void FindElementOneByEmpty() { Mockery mock = new Mockery(); IAllDriver driver = mock.NewMock <IAllDriver>(); var elems = new List <IWebElement>().AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems)); ByChained by = new ByChained(By.Name("cheese")); try { by.FindElement(driver); Assert.Fail("Expected NoSuchElementException!"); } catch (NoSuchElementException) { mock.VerifyAllExpectationsHaveBeenMet(); Assert.Pass(); } }
public void FindElementsTwoByEmptyChild() { Mockery mocks = new Mockery(); IAllDriver driver = mocks.NewMock<IAllDriver>(); IAllElement elem1 = mocks.NewMock<IAllElement>(); IAllElement elem2 = mocks.NewMock<IAllElement>(); IAllElement elem3 = mocks.NewMock<IAllElement>(); IAllElement elem4 = mocks.NewMock<IAllElement>(); IAllElement elem5 = mocks.NewMock<IAllElement>(); var elems = new List<IWebElement>().AsReadOnly(); var elems12 = new List<IWebElement>() { elem1, elem2 }.AsReadOnly(); var elems34 = new List<IWebElement>() { elem3, elem4 }.AsReadOnly(); var elems5 = new List<IWebElement>() { elem5 }.AsReadOnly(); var elems345 = new List<IWebElement>() { elem3, elem4, elem5 }.AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12)); Expect.Once.On(elem1).Method("FindElements").With(By.Name("photo")).Will(Return.Value(elems)); Expect.Once.On(elem2).Method("FindElements").With(By.Name("photo")).Will(Return.Value(elems5)); ByChained by = new ByChained(By.Name("cheese"), By.Name("photo")); Assert.That(by.FindElements(driver), Is.EqualTo(new[] { elem5 })); mocks.VerifyAllExpectationsHaveBeenMet(); }
/// <summary> /// Creates a list of <see cref="By"/> locators based on the attributes of this member. /// </summary> /// <param name="member">The <see cref="MemberInfo"/> containing information about /// the member of the Page Object class.</param> /// <returns>A list of <see cref="By"/> locators based on the attributes of this member.</returns> protected static ReadOnlyCollection<By> CreateLocatorList(MemberInfo member) { if (member == null) { throw new ArgumentNullException("member", "memeber cannot be null"); } var useSequenceAttributes = Attribute.GetCustomAttributes(member, typeof(FindsBySequenceAttribute), true); bool useSequence = useSequenceAttributes.Length > 0; var useFindAllAttributes = Attribute.GetCustomAttributes(member, typeof(FindsByAllAttribute), true); bool useAll = useFindAllAttributes.Length > 0; if (useSequence && useAll) { throw new ArgumentException("Cannot specify FindsBySequence and FindsByAll on the same member"); } List<By> bys = new List<By>(); var attributes = Attribute.GetCustomAttributes(member, typeof(FindsByAttribute), true); if (attributes.Length > 0) { Array.Sort(attributes); foreach (var attribute in attributes) { var castedAttribute = (FindsByAttribute)attribute; if (castedAttribute.Using == null) { castedAttribute.Using = member.Name; } bys.Add(castedAttribute.Finder); } if (useSequence) { ByChained chained = new ByChained(bys.ToArray()); bys.Clear(); bys.Add(chained); } if (useAll) { ByAll all = new ByAll(bys.ToArray()); bys.Clear(); bys.Add(all); } } return bys.AsReadOnly(); }
public void FindElementsTwoByEmptyParent() { Mockery mocks = new Mockery(); IAllDriver driver = mocks.NewMock<IAllDriver>(); var elems = new List<IWebElement>().AsReadOnly(); Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems)); ByChained by = new ByChained(By.Name("cheese"), By.Name("photo")); Assert.That(by.FindElements(driver), Is.EqualTo(elems)); mocks.VerifyAllExpectationsHaveBeenMet(); }