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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #6
0
        public void FindElementZeroBy()
        {
            Mock <IAllDriver> driver = new Mock <IAllDriver>();

            ByChained by = new ByChained();

            Assert.Throws <NoSuchElementException>(() => by.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);
        }
Beispiel #8
0
        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()
        {
            MockFactory       mock   = new MockFactory();
            Mock <IAllDriver> driver = mock.CreateMock <IAllDriver>();

            ByChained by = new ByChained();

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.MockObject));
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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();

            by.FindElement(driver);
        }
Beispiel #13
0
        public void FindElementZeroBy()
        {
            Mockery    mock   = new Mockery();
            IAllDriver driver = mock.NewMock <IAllDriver>();

            ByChained by = new ByChained();

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver));
        }
Beispiel #14
0
        public void FindElementOneBy()
        {
            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.FindElement(driver), elem1);
            mock.VerifyAllExpectationsHaveBeenMet();
        }
        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();
            }
        }
Beispiel #16
0
        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();
            }
        }
Beispiel #17
0
        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();
            }
        }
Beispiel #18
0
        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 FindElementOneBy()
        {
            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.FindElement(driver.MockObject), elem1.MockObject);
            mock.VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #20
0
        public void FindElementOneBy()
        {
            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.FindElement(driver), elem1);
            mock.VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #21
0
        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();
            }
        }
Beispiel #22
0
        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()
        {
            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();
            }
        }
Beispiel #24
0
        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();
            }
        }
Beispiel #25
0
        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 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();
            }
        }