public void ShouldGoToPageEnterTextAndClickButton()
 {
     using (var I = new FluentDriver(new FirefoxDriver(null, new FirefoxProfile { EnableNativeEvents = false })))
     {
         I.OpenPage(google);
         I.EnterText("cats").Into("input[name=\"q\"]");
         I.Click().On("input[name=\"btnK\"]");
     }
 }
 public void ShouldGoToPageEnterTextClickButtonAndWaitForElementsToAppear()
 {
     using (var I = new FluentDriver(new FirefoxDriver(null, new FirefoxProfile { EnableNativeEvents = false })))
     {
         I.OpenPage(google);
         I.EnterText("cats").Into("input[name=\"q\"]");
         Action act = () => I.Expect().ValueOf("input[name=\"q\"]").ToBe("cats");
         act.ShouldNotThrow<Exception>();
     }
 }
 public void ShouldNotWaitForElementsToAppearAndThrow()
 {
     using (var I = new FluentDriver(new FirefoxDriver(null, new FirefoxProfile { EnableNativeEvents = false })))
     {
         I.OpenPage(google);
         I.EnterText("cats").Into("input[name=\"q\"]");
         I.Click().On("input[name=\"btnK\"]");
         Action act = () => { I.Expect().ValueOf("lst-ib").ToBe("cats"); };
         act.ShouldThrow<Exception>();
     }
 }
        public void ShouldBeAbleToVerifyIfValueOfElementMatches()
        {
            var driver = new Mock<IWebDriver>();
            var webElement = new Mock<IWebElement>();

            webElement.Setup(e => e.GetAttribute("value")).Returns("foo");
            driver.Setup(d => d.FindElement(It.IsAny<By>())).Returns(webElement.Object);

            using (var I = new FluentDriver(driver.Object))
            {
                Action act = () => I.Expect().ValueOf("input").ToBe("foo");
                act.ShouldNotThrow();
            }
        }
        public void CanVerifyValueOfTextbox()
        {
            using (var I = new FluentDriver(new FirefoxDriver(null, new FirefoxProfile { EnableNativeEvents = false })))
            {
                I.OpenPage(google);
                I.EnterText("cats").Into("input[name=\"q\"]");

                Action toBeAction = () => I.Expect().ValueOf("input[name=\"q\"]").ToBe("cats");
                toBeAction.ShouldNotThrow<Exception>();

                Action notToBeAction = () => I.Expect().ValueOf("input[name=\"q\"]").NotToBe("dogs");
                notToBeAction.ShouldNotThrow<Exception>();
            }
        }
        public void ShouldGoToPage()
        {
            var driver = new Mock<IWebDriver>();
            var navigation = new Mock<INavigation>();

            driver.Setup(d => d.Navigate()).Returns(navigation.Object);
            navigation.Setup(n => n.GoToUrl(It.IsAny<string>())).Verifiable();

            using (var I = new FluentDriver(driver.Object))
            {
                I.OpenPage("http://www.google.com");
            }

            navigation.Verify();
        }
Ejemplo n.º 7
0
        public void ShouldBeAbleToClickOnAnElement()
        {
            var driver = new Mock<IWebDriver>();
            var webElement = new Mock<IWebElement>();

            webElement.Setup(e => e.Click()).Verifiable();
            driver.Setup(d => d.FindElement(It.IsAny<By>())).Returns(webElement.Object).Verifiable();

            using (var I = new FluentDriver(driver.Object))
            {
                I.Click().On("#search");
            }

            driver.Verify();
            webElement.Verify();
        }
Ejemplo n.º 8
0
        public void ShouldBeAbleToReadValueOfTextInput()
        {
            var driver = new Mock<IWebDriver>();
            var webElement = new Mock<IWebElement>();

            webElement.Setup(e => e.GetAttribute("value")).Returns("foo").Verifiable();
            driver.Setup(d => d.FindElement(It.IsAny<By>())).Returns(webElement.Object).Verifiable();

            using (var I = new FluentDriver(driver.Object))
            {
                I.Expect().ValueOf("input").ToBe("foo");
            }

            driver.Verify();
            webElement.Verify();
        }
Ejemplo n.º 9
0
        public void ShouldBeAbleToFindAnElement()
        {
            var driver = new Mock<IWebDriver>();
            var webElement = new Mock<IWebElement>();

            webElement.Setup(e => e.SendKeys(It.IsAny<string>())).Verifiable();

            driver.Setup(d => d.FindElement(It.IsAny<By>())).Returns(webElement.Object).Verifiable();

            using (var I = new FluentDriver(driver.Object))
            {
                I.EnterText("cats").Into("#gbqfq");
            }

            driver.Verify();
            webElement.Verify();
        }
Ejemplo n.º 10
0
        public void ShouldExpect4Items()
        {
            var driver = new Mock<IWebDriver>();
            var elementsList = new List<IWebElement>
            {
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@")
            };

            var foundElements = new ReadOnlyCollection<IWebElement>(elementsList);
            driver.Setup(el => el.FindElements(It.IsAny<By>())).Returns(foundElements);

            using (var I = new FluentDriver(driver.Object))
            {
                I.Expect().TheNumberOf("ds").ToBe().Exactly(4);
            }
        }
        public void ShouldThrowExceptionIfIntegerValueOfElementDoesNotMatchWhenExpectedTo()
        {
            var driver = new Mock<IWebDriver>();
            var webElement = new Mock<IWebElement>();

            webElement.Setup(e => e.GetAttribute("value")).Returns("7");
            driver.Setup(d => d.FindElement(It.IsAny<By>())).Returns(webElement.Object);

            using (var I = new FluentDriver(driver.Object))
            {
                Action act = () => I.Expect().ValueOf("input").ToBe("34");
                act.ShouldThrow<Exception>();
            }
        }
Ejemplo n.º 12
0
        public void ShouldWaitForCheckingVisibilityWithIn1Second()
        {
            var driver = new Mock<IWebDriver>();
            var webElement = new Mock<IWebElement>();

            webElement.Setup(e => e.Displayed).Returns(true).Verifiable();
            driver.Setup(d => d.FindElement(It.IsAny<By>())).Returns(webElement.Object).Verifiable();

            using (var I = new FluentDriver(driver.Object))
            {
                I.Expect().ToSee("#id").WithIn(1000);
            }
        }
Ejemplo n.º 13
0
        public void ShouldExpectLessThan3ItemsAndThrow()
        {
            var driver = new Mock<IWebDriver>();
            var elementsList = new List<IWebElement>
            {
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@"),
                new FirefoxWebElement(null, "@")
            };

            var foundElements = new ReadOnlyCollection<IWebElement>(elementsList);
            driver.Setup(el => el.FindElements(It.IsAny<By>())).Returns(foundElements);

            using (var I = new FluentDriver(driver.Object))
            {
                Action act = () => { I.Expect().TheNumberOf("ds").ToBe().LessThan(4); };
                act.ShouldThrow<Exception>();
            }
        }