示例#1
0
        private void PerformXenonAction(Func <BaseXenonTest <T>, BaseXenonTest <T> > xenonAction)
        {
            var html = XenonTestsResourceLookup.GetContent("DoesNotContain");

            using (var browserTest = new BrowserTest(html))
            {
                var browser = browserTest.Start();
                xenonAction(CreateInstance(browser).GoToUrl("/"));
            }
        }
示例#2
0
 public void EnterText_WhenTextElementIsDatePicker_ThrowsException()
 {
     using (var browserTest = new BrowserTest(GetHtml()))
     {
         Assert.Throws <IncorrectInputElementTypeException>(() => {
             CreateInstance(browserTest.Start())
             .GoToUrl("/")
             .EnterText("input[type=\"date\"]", new DateTime(2000, 1, 1).ToString());
         });
     }
 }
        private void StartTest(string fileName, Func <XenonTest, XenonTest> testFunc)
        {
            var html = XenonTestsResourceLookup.GetContent(fileName);

            using (var bt = new BrowserTest(html))
            {
                var browser   = bt.Start();
                var xenonTest = new XenonTest(browser)
                                .GoToUrl("/");
                testFunc(xenonTest);
            }
        }
示例#4
0
        public void GettingTextOfInput_ReturnsValueOfInput(string inputType, string expectedValue)
        {
            var html = XenonTestsResourceLookup.GetContent("InputTests");

            using (var browserTest = new BrowserTest(html))
            {
                var browser = browserTest.Start();

                new DummyXenonScreen(browser)
                .GoToUrl("/")
                .Assert(x => x.CustomAssertion(y => y.FindElementsByCssSelector(String.Format("input[type='{0}']", inputType)).First().Text == expectedValue));
            }
        }
示例#5
0
        public void GettingTextOfInput_ReturnsValueOfInput(string inputType, string expectedValue)
        {
            var html = XenonTestsResourceLookup.GetContent("InputTests");

            using (var browserTest = new BrowserTest(html))
            {
                var browser = browserTest.Start();

                new DummyXenonScreen(browser)
                .GoToUrl("/")
                .Assert(x => InputHasExpectedValue(inputType, expectedValue, x));
            }
        }
示例#6
0
 public void AssertPageContains_WithElementsOnPage_ChecksInputValues()
 {
     var html = XenonTestsResourceLookup.GetContent( "PageWithInputs" );
     using ( var bt = new BrowserTest( html ) )
     {
         var browser = bt.Start();
         CreateInstance( browser )
             .GoToUrl( "/" )
             .Click( where => where.TextIs( "Fill Form" ) )
             .Assert( a => a.PageContains( "First Name" ) )
             .Assert( a => a.PageContains( "Description Content" ) );
     }
 }
        private void ArrangeActAndAssert(string linkText, string assertResultContainsText)
        {
            var html = XenonTestsResourceLookup.GetContent("PageWithDialogBoxes");

            using (var bt = new BrowserTest(html))
            {
                var browser = bt.Start();
                CreateInstance(browser)
                .GoToUrl("/")
                .Click(where => where.TextIs(linkText))
                .ClickDialogBox()
                .Assert(a => a.ContainsElement(where => where.TextIs(assertResultContainsText)));
            }
        }
        public void CancelDialogBox_DialogBoxIsActive_CancelDialogBox()
        {
            var html = XenonTestsResourceLookup.GetContent("PageWithDialogBoxes");

            using (var bt = new BrowserTest(html))
            {
                var browser = bt.Start();
                CreateInstance(browser)
                .GoToUrl("/")
                .Click(where => where.TextIs("Confirm Box"))
                .CancelDialogBox()
                .Assert(a => a.ContainsElement(where => where.TextIs("Cancelled Confirm Dialog box")));
            }
        }
示例#9
0
        public void ClickDialogBox_AlertDialogBoxIsActive_ClickIt()
        {
            var html = XenonTestsResourceLookup.GetContent("ScrollToElement");

            using (var bt = new BrowserTest(html))
            {
                var browser = bt.Start();
                CreateInstance(browser)
                .GoToUrl("/")
                .Click(where => where.TextIs("Click"));

                Assert.AreEqual("worked", bt.GetPostResult()["temp"]);
            }
        }
        public void MoveToElement_WhenMovingToElement_MovesToElement()
        {
            var html = XenonTestsResourceLookup.GetContent("MoveToElement");

            using (var browserTest = new BrowserTest(html))
            {
                var browser = browserTest.Start();

                CreateInstance(browser)
                .GoToUrl("/")
                .MoveToElement("#element");

                Assert.AreEqual("worked", browserTest.GetPostResult()["temp"]);
            }
        }
        public void CanCloseAndSwitchToAnotherWindow()
        {
            var html = XenonTestsResourceLookup.GetContent("SwitchBetweenMultipleWindows");

            using (var browserTest = new BrowserTest(html))
            {
                var browser = browserTest.Start();
                CreateInstance(browser)
                .GoToUrl("/")
                .Click(where => where.TextIs("Google"))
                .SwitchToWindow(a => a.PageContains("I'm Feeling Lucky"))
                .Assert(a => a.PageContains("I'm Feeling Lucky"))
                .CloseCurrentAndSwitchToWindow(a => a.PageContains("Test Page"))
                .Assert(a => a.PageContains("Test Page"));
            }
        }
        public void EnterTextInDialogBox_PromptDialogBoxIsActive_CanEnterTextInIt()
        {
            const string text = "Test1234";

            var html = XenonTestsResourceLookup.GetContent("PageWithDialogBoxes");

            using (var bt = new BrowserTest(html))
            {
                var browser = bt.Start();
                CreateInstance(browser)
                .GoToUrl("/")
                .Click(where => where.TextIs("Prompt Box Enter Text"))
                .EnterTextInDialogBox(text)
                .ClickDialogBox()
                .Assert(a => a.ContainsElement(where => where.TextIs(text)));
            }
        }
示例#13
0
        public void SelectList_WhenDelayBeforeResultsAreDisplayed_SelectsValue()
        {
            using (
                var browserTest =
                    new BrowserTest(GetEmbeddedResource("Xenon.Tests.SelectListTests.SelectListTests.html")))
            {
                var browser = browserTest.Start();

                CreateInstance(browser)
                .GoToUrl("/")
                .SelectList("[name='delayed-select-list']", "Third")
                .Click(where => where.TextIs("Submit"));

                var postResult = browserTest.GetPostResult();

                Assert.AreEqual("3", postResult["delayed-select-list"]);
            }
        }
示例#14
0
        public void EnterDateIntoDatePicker_DoesSetValue(BrowserType browserType)
        {
            using (var browserTest = new BrowserTest(GetHtml()))
            {
                var theFifthOfNovember = new DateTime(1605, 11, 5);

                CreateInstance(browserTest.Start(browserType))
                .GoToUrl("/")
                .EnterDate("input[name=\"date\"]", theFifthOfNovember)
                .Click(x => x.TextIs("Submit"));

                Assert.AreEqual(theFifthOfNovember, GetPostedDateValue());

                DateTime GetPostedDateValue()
                {
                    var postResult = browserTest.GetPostResult();

                    return(DateTime.Parse(postResult["date"]));
                }
            }
        }