コード例 #1
0
ファイル: ByAllTests.cs プロジェクト: hafizatiq/selenium-test
        public void FindElementDisjunct()
        {
            var driver = new Mock <IAllDriver>();

            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elem3 = new Mock <IAllElement>();
            var elem4 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();
            var elems34 = new List <IWebElement> {
                elem3.Object, elem4.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12);
            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "photo"))).Returns(elems34);

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.Object));

            var result = by.FindElements(driver.Object);

            Assert.That(result.Count, Is.EqualTo(0));
            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
            driver.Verify(_ => _.FindElementsByName("photo"), Times.AtLeastOnce);
        }
コード例 #2
0
ファイル: ByAllTests.cs プロジェクト: vaxouris/selenium_edge
        public void FindElementTwoBy()
        {
            var mocks  = new Mockery();
            var driver = mocks.NewMock <IAllDriver>();

            var elem1 = mocks.NewMock <IAllElement>();
            var elem2 = mocks.NewMock <IAllElement>();
            var elem3 = mocks.NewMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1, elem2
            }.AsReadOnly();
            var elems23 = new List <IWebElement> {
                elem2, elem3
            }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems23));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver), Is.EqualTo(elem2));

            //findElements
            var result = by.FindElements(driver);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2));

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #3
0
        public void FindElementDisjunct()
        {
            var mocks  = new MockFactory();
            var driver = mocks.CreateMock <IAllDriver>();

            var elem1 = mocks.CreateMock <IAllElement>();
            var elem2 = mocks.CreateMock <IAllElement>();
            var elem3 = mocks.CreateMock <IAllElement>();
            var elem4 = mocks.CreateMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.MockObject, elem2.MockObject
            }.AsReadOnly();
            var elems34 = new List <IWebElement> {
                elem3.MockObject, elem4.MockObject
            }.AsReadOnly();

            driver.Expects.AtLeastOne.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems12);
            driver.Expects.AtLeastOne.Method(_ => _.FindElementsByName(null)).With("photo").WillReturn(elems34);

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.MockObject));

            var result = by.FindElements(driver.MockObject);

            Assert.That(result.Count, Is.EqualTo(0));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #4
0
ファイル: ByAllTests.cs プロジェクト: hafizatiq/selenium-test
        public void FindElementTwoBy()
        {
            var driver = new Mock <IAllDriver>();

            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elem3 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();
            var elems23 = new List <IWebElement> {
                elem2.Object, elem3.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12);
            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "photo"))).Returns(elems23);

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver.Object), Is.EqualTo(elem2.Object));

            //findElements
            var result = by.FindElements(driver.Object);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2.Object));

            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
            driver.Verify(_ => _.FindElementsByName("photo"), Times.AtLeastOnce);
        }
コード例 #5
0
ファイル: ByAllTests.cs プロジェクト: vaxouris/selenium_edge
        public void FindElementDisjunct()
        {
            var mocks  = new Mockery();
            var driver = mocks.NewMock <IAllDriver>();

            var elem1 = mocks.NewMock <IAllElement>();
            var elem2 = mocks.NewMock <IAllElement>();
            var elem3 = mocks.NewMock <IAllElement>();
            var elem4 = mocks.NewMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1, elem2
            }.AsReadOnly();
            var elems34 = new List <IWebElement> {
                elem3, elem4
            }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems34));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver));

            var result = by.FindElements(driver);

            Assert.That(result.Count, Is.EqualTo(0));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #6
0
        public void FindElementTwoBy()
        {
            var mocks  = new MockFactory();
            var driver = mocks.CreateMock <IAllDriver>();

            var elem1 = mocks.CreateMock <IAllElement>();
            var elem2 = mocks.CreateMock <IAllElement>();
            var elem3 = mocks.CreateMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.MockObject, elem2.MockObject
            }.AsReadOnly();
            var elems23 = new List <IWebElement> {
                elem2.MockObject, elem3.MockObject
            }.AsReadOnly();

            driver.Expects.AtLeastOne.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems12);
            driver.Expects.AtLeastOne.Method(_ => _.FindElementsByName(null)).With("photo").WillReturn(elems23);

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver.MockObject), Is.EqualTo(elem2.MockObject));

            //findElements
            var result = by.FindElements(driver.MockObject);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2.MockObject));

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #7
0
ファイル: ByAllTests.cs プロジェクト: hafizatiq/selenium-test
        public void FindElementZeroBy()
        {
            var driver = new Mock <IAllDriver>();

            var by = new ByAll();

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.Object));
            Assert.That(by.FindElements(driver.Object), Is.EqualTo(new List <IWebElement>().AsReadOnly()));
        }
コード例 #8
0
ファイル: ByAllTests.cs プロジェクト: RanchoLi/selenium
        public void FindElementZeroBy()
        {
            var mock = new Mockery();
            var driver = mock.NewMock<IAllDriver>();

            var by = new ByAll();

            Assert.Throws<NoSuchElementException>(() => by.FindElement(driver));
            Assert.That(by.FindElements(driver), Is.EqualTo(new List<IWebElement>().AsReadOnly()));
        }
コード例 #9
0
ファイル: ByAllTests.cs プロジェクト: hafizatiq/selenium-test
        public void FindElementOneByEmpty()
        {
            var driver = new Mock <IAllDriver>();
            var empty  = new List <IWebElement>().AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(empty);

            var by = new ByAll(By.Name("cheese"));

            // one element
            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.Object));
            Assert.That(by.FindElements(driver.Object), Is.EqualTo(empty));

            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
        }
コード例 #10
0
ファイル: ByAllTests.cs プロジェクト: vaxouris/selenium_edge
        public void FindElementOneByEmpty()
        {
            var mock   = new Mockery();
            var driver = mock.NewMock <IAllDriver>();
            var empty  = new List <IWebElement>().AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(empty));

            var by = new ByAll(By.Name("cheese"));

            // one element
            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver));
            Assert.That(by.FindElements(driver), Is.EqualTo(empty));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #11
0
ファイル: ByAllTests.cs プロジェクト: RanchoLi/selenium
        public void FindElementOneByEmpty()
        {
            var mock = new Mockery();
            var driver = mock.NewMock<IAllDriver>();
            var empty = new List<IWebElement>().AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(empty));

            var by = new ByAll(By.Name("cheese"));

            // one element
            Assert.Throws<NoSuchElementException>(() => by.FindElement(driver));
            Assert.That(by.FindElements(driver), Is.EqualTo(empty));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #12
0
        public void FindElementOneByEmpty()
        {
            var mock   = new MockFactory();
            var driver = mock.CreateMock <IAllDriver>();
            var empty  = new List <IWebElement>().AsReadOnly();

            driver.Expects.AtLeastOne.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(empty);

            var by = new ByAll(By.Name("cheese"));

            // one element
            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.MockObject));
            Assert.That(by.FindElements(driver.MockObject), Is.EqualTo(empty));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #13
0
ファイル: ByAllTests.cs プロジェクト: RanchoLi/selenium
        public void FindElementOneBy()
        {
            var mock = new Mockery();
            var driver = mock.NewMock<IAllDriver>();
            var elem1 = mock.NewMock<IAllElement>();
            var elem2 = mock.NewMock<IAllElement>();
            var elems12 = new List<IWebElement> { elem1, elem2 }.AsReadOnly();
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            var by = new ByAll(By.Name("cheese"));

            // findElement
            Assert.AreEqual(by.FindElement(driver), elem1);
            //findElements
            Assert.That(by.FindElements(driver), Is.EqualTo(elems12));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #14
0
ファイル: ByAllTests.cs プロジェクト: hafizatiq/selenium-test
        public void FindElementOneBy()
        {
            var driver = new Mock <IAllDriver>();
            var elem1 = new Mock <IAllElement>();
            var 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);
            var by = new ByAll(By.Name("cheese"));

            // findElement
            Assert.AreEqual(by.FindElement(driver.Object), elem1.Object);
            //findElements
            Assert.That(by.FindElements(driver.Object), Is.EqualTo(elems12));

            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
        }
コード例 #15
0
ファイル: ByAllTests.cs プロジェクト: vaxouris/selenium_edge
        public void FindElementOneBy()
        {
            var mock = new Mockery();
            var driver = mock.NewMock <IAllDriver>();
            var elem1 = mock.NewMock <IAllElement>();
            var elem2 = mock.NewMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1, elem2
            }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            var by = new ByAll(By.Name("cheese"));

            // findElement
            Assert.AreEqual(by.FindElement(driver), elem1);
            //findElements
            Assert.That(by.FindElements(driver), Is.EqualTo(elems12));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #16
0
        public void FindElementOneBy()
        {
            var mock = new MockFactory();
            var driver = mock.CreateMock <IAllDriver>();
            var elem1 = mock.CreateMock <IAllElement>();
            var elem2 = mock.CreateMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.MockObject, elem2.MockObject
            }.AsReadOnly();

            driver.Expects.AtLeastOne.Method(_ => _.FindElementsByName(null)).With("cheese").WillReturn(elems12);
            var by = new ByAll(By.Name("cheese"));

            // findElement
            Assert.AreEqual(by.FindElement(driver.MockObject), elem1.MockObject);
            //findElements
            Assert.That(by.FindElements(driver.MockObject), Is.EqualTo(elems12));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #17
0
ファイル: ByAllTests.cs プロジェクト: RanchoLi/selenium
        public void FindElementTwoBy()
        {
            var mocks = new Mockery();
            var driver = mocks.NewMock<IAllDriver>();

            var elem1 = mocks.NewMock<IAllElement>();
            var elem2 = mocks.NewMock<IAllElement>();
            var elem3 = mocks.NewMock<IAllElement>();
            var elems12 = new List<IWebElement> { elem1, elem2 }.AsReadOnly();
            var elems23 = new List<IWebElement> { elem2, elem3 }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems23));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver), Is.EqualTo(elem2));

            //findElements
            var result = by.FindElements(driver);
            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2));

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #18
0
ファイル: ByAllTests.cs プロジェクト: RanchoLi/selenium
        public void FindElementDisjunct()
        {
            var mocks = new Mockery();
            var driver = mocks.NewMock<IAllDriver>();

            var elem1 = mocks.NewMock<IAllElement>();
            var elem2 = mocks.NewMock<IAllElement>();
            var elem3 = mocks.NewMock<IAllElement>();
            var elem4 = mocks.NewMock<IAllElement>();
            var elems12 = new List<IWebElement> { elem1, elem2 }.AsReadOnly();
            var elems34 = new List<IWebElement> { elem3, elem4 }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems34));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));
            
            Assert.Throws<NoSuchElementException>(() => by.FindElement(driver));

            var result = by.FindElements(driver);
            Assert.That(result.Count, Is.EqualTo(0));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }