public void FindElements_ShouldReturnMultiple()
        {
            driver.Url = nestedPage;
            driver.Navigate();

            var by = new ByChained(By.Name("div1"));
            Assert.AreEqual(4, by.FindElements(driver).Count);
        }
Esempio n. 2
0
        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()));
        }
Esempio n. 3
0
        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()));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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 FindElementsNotFound_ShouldBeZero()
        {
            driver.Url = nestedPage;
            driver.Navigate();

            var by = new ByChained(By.Name("NotFoundAtAll"));
                
            Assert.AreEqual(0, by.FindElements(driver).Count);
        }
Esempio n. 7
0
        public void FindElementsNotFound_ShouldBeZero()
        {
            driver.Url = nestedPage;
            driver.Navigate();

            var by = new ByChained(By.Name("NotFoundAtAll"));

            Assert.AreEqual(0, by.FindElements(driver).Count);
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        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));
        }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
        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();
        }
Esempio n. 13
0
        public void FindElementsTwoByEmptyParent()
        {
            MockFactory       mocks  = new MockFactory();
            Mock <IAllDriver> driver = mocks.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"), By.Name("photo"));

            Assert.That(by.FindElements(driver.MockObject), Is.EqualTo(elems));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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();
        }
Esempio n. 17
0
        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();
        }
Esempio n. 18
0
        public void FindElementsTwoByEmptyChild()
        {
            Mock <IAllDriver> driver = new Mock <IAllDriver>();

            Mock <IAllElement> elem1 = new Mock <IAllElement>();
            Mock <IAllElement> elem2 = new Mock <IAllElement>();
            Mock <IAllElement> elem3 = new Mock <IAllElement>();
            Mock <IAllElement> elem4 = 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 elems34 = new List <IWebElement>()
            {
                elem3.Object, elem4.Object
            }.AsReadOnly();
            var elems5 = new List <IWebElement>()
            {
                elem5.Object
            }.AsReadOnly();
            var elems345 = new List <IWebElement>()
            {
                elem3.Object, elem4.Object, 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.FindElements(driver.Object), Is.EqualTo(new[] { elem5.Object }));
            driver.Verify(_ => _.FindElementsByName("cheese"), Times.Once);
            elem1.Verify(_ => _.FindElements(By.Name("photo")), Times.Once);
            elem2.Verify(_ => _.FindElements(By.Name("photo")), Times.Once);
        }
Esempio n. 19
0
        public void FindElementsTwoByEmptyChild()
        {
            MockFactory       mocks  = new MockFactory();
            Mock <IAllDriver> driver = mocks.CreateMock <IAllDriver>();

            Mock <IAllElement> elem1 = mocks.CreateMock <IAllElement>();
            Mock <IAllElement> elem2 = mocks.CreateMock <IAllElement>();
            Mock <IAllElement> elem3 = mocks.CreateMock <IAllElement>();
            Mock <IAllElement> elem4 = 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 elems34 = new List <IWebElement>()
            {
                elem3.MockObject, elem4.MockObject
            }.AsReadOnly();
            var elems5 = new List <IWebElement>()
            {
                elem5.MockObject
            }.AsReadOnly();
            var elems345 = new List <IWebElement>()
            {
                elem3.MockObject, elem4.MockObject, 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.FindElements(driver.MockObject), Is.EqualTo(new[] { elem5.MockObject }));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Esempio n. 20
0
        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();
        }
        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);
        }
Esempio n. 22
0
        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();
        }
Esempio n. 23
0
        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();
        }