コード例 #1
0
        public void Feature_JavascriptEvents_JavascriptEvents()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_JavascriptEvents_JavascriptEvents);

                // init alert
                browser.Wait();
                AssertUI.AlertTextEquals(browser, "init");
                browser.ConfirmAlert();

                // postback alerts
                browser.ElementAt("input[type=button]", 0).Click();

                AssertUI.AlertTextEquals(browser, "beforePostback");
                browser.ConfirmAlert();
                browser.Wait();

                AssertUI.AlertTextEquals(browser, "afterPostback");
                browser.ConfirmAlert();

                // error alerts
                browser.ElementAt("input[type=button]", 1).Click();

                AssertUI.AlertTextEquals(browser, "beforePostback");
                browser.ConfirmAlert();
                browser.Wait();

                AssertUI.AlertTextEquals(browser, "custom error handler");
                browser.ConfirmAlert();
            });
        }
コード例 #2
0
        public void Feature_ServerSideStyles_ControlProperties()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_ServerSideStyles_ServerSideStyles_ControlProperties);

                browser.First("input[server-side-style-attribute]").Click();
                AssertUI.AlertTextEquals(browser, "ConfirmPostBackHandler Content");
            });
        }
コード例 #3
0
        public void Test()
        {
            RunInAllBrowsers(browser =>
            {
                browser.NavigateToUrl("/test/alert");

                browser.First("#button").Click();
                AssertUI.AlertTextEquals(browser, "confirm test");
            });
        }
コード例 #4
0
ファイル: ResourcesTests.cs プロジェクト: vnwonah/dotvvm
        public void Feature_Resources_CdnScriptPriority()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_Resources_CdnScriptPriority);

                // verify that if CDN is not available, local script loads
                browser.WaitFor(browser.HasAlert, 5000, "An alert was expected to open!");
                AssertUI.AlertTextEquals(browser, "javascript resource loaded!");
                browser.ConfirmAlert();
            });
        }
コード例 #5
0
ファイル: ResourcesTests.cs プロジェクト: vnwonah/dotvvm
        public void Feature_Resources_OnlineNonameResourceLoad()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_Resources_OnlineNonameResourceLoad);

                //click button
                browser.First("input[type=button]").Click();

                //check that alert showed
                browser.WaitFor(browser.HasAlert, 5000, "An alert was expected to open!");
                AssertUI.AlertTextEquals(browser, "resource loaded");
                browser.ConfirmAlert();
            });
        }
コード例 #6
0
ファイル: ResourcesTests.cs プロジェクト: vnwonah/dotvvm
        public void Feature_Resource_RequiredOnPostback()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_Resources_RequiredOnPostback);
                browser.WaitUntilDotvvmInited();

                var welcome = browser.Single("welcome", SelectByDataUi);
                AssertUI.TextEquals(welcome, "Welcome");

                browser.Single("button", SelectByDataUi).Click();
                browser.WaitFor(() => AssertUI.AlertTextEquals(browser, "javascript resource loaded!"), 5000);

                browser.ConfirmAlert();
                browser.WaitFor(() => AssertUI.TextEquals(welcome, "Welcome"), 1000);
            });
        }
コード例 #7
0
        public void Control_SpaContentPlaceHolder_SpaContentPlaceHolder()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_Default);
                browser.Wait(2000);

                // verify the URL after redirect to the DefaultRoute
                AssertUI.AlertTextEquals(browser, "javascript 2 resource loaded!");
                browser.ConfirmAlert();
                browser.Wait(2000);
                AssertUI.AlertTextEquals(browser, "javascript resource loaded!");
                browser.ConfirmAlert();
                AssertUI.UrlEquals(browser, browser.BaseUrl + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_Default + "#!/" + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_PageB);

                // go to first page
                browser.First("a").Click();
                browser.Wait();
                AssertUI.UrlEquals(browser, browser.BaseUrl + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_Default + "#!/" + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_PageA + "/16");

                // test first page
                AssertUI.TextEquals(browser.ElementAt("span", 0), "0");
                browser.Click("input[type=button]");
                browser.Wait();
                browser.Click("input[type=button]");
                browser.Wait();
                browser.Click("input[type=button]");
                browser.Wait();
                AssertUI.TextEquals(browser.ElementAt("span", 0), "3");

                // go to second page
                browser.FindElements("a").Single(l => l.GetText() == "Go to Task List").Click();
                browser.Wait();
                AssertUI.UrlEquals(browser, browser.BaseUrl + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_Default + "#!/" + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_PageB);

                // try the task list
                browser.FindElements(".table tr").ThrowIfDifferentCountThan(3);
                browser.SendKeys("input[type=text]", "DotVVM rocks!");
                browser.Click("input[type=button]");
                browser.Wait();
                browser.FindElements(".table tr").ThrowIfDifferentCountThan(4);
                browser.Last("tr a").Click();
                browser.Wait();
                AssertUI.HasClass(browser.Last(".table tr"), "completed");

                // test the browse back button
                browser.NavigateBack();
                browser.Wait();
                AssertUI.UrlEquals(browser, browser.BaseUrl + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_Default + "#!/" + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_PageA + "/16");

                // test first page
                AssertUI.TextEquals(browser.ElementAt("span", 0), "0");
                browser.Click("input[type=button]");
                browser.Wait();
                browser.Click("input[type=button]");
                browser.Wait();
                browser.Click("input[type=button]");
                browser.Wait();
                AssertUI.TextEquals(browser.ElementAt("span", 0), "3");

                // test the forward button
                browser.NavigateForward();
                browser.Wait();

                // test the redirect inside SPA
                browser.FindElements(".table tr").ThrowIfDifferentCountThan(3);
                browser.Last("input[type=button]").Click();
                browser.Wait(2000);
                AssertUI.UrlEquals(browser, browser.BaseUrl + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_Default + "#!/" + SamplesRouteUrls.ControlSamples_SpaContentPlaceHolder_PageA + "/15");

                // test the redirect outside SPA
                AssertUI.TextEquals(browser.ElementAt("span", 0), "0");
                browser.FindElements("a").Single(l => l.GetText().Contains("Exit SPA")).Click();
                browser.Wait();
                AssertUI.UrlEquals(browser, browser.BaseUrl + SamplesRouteUrls.ComplexSamples_TaskList_ServerRenderedTaskList);
            });
        }
コード例 #8
0
        private void ValidatePostbackHandlersComplexSection(string sectionSelector, IBrowserWrapper browser)
        {
            IElementWrapper section = null;

            browser.WaitFor(() => {
                section = browser.First(sectionSelector);
            }, 2000, "Cannot find static commands section.");

            var index = browser.First("[data-ui=\"command-index\"]");

            // confirm first
            section.ElementAt("input[type=button]", 0).Click();
            AssertUI.AlertTextEquals(browser, "Confirmation 1");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "1");

            // cancel second
            section.ElementAt("input[type=button]", 1).Click();
            AssertUI.AlertTextEquals(browser, "Confirmation 1");
            browser.ConfirmAlert();
            browser.Wait();

            AssertUI.AlertTextEquals(browser, "Confirmation 2");
            browser.DismissAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "1");
            // confirm second
            section.ElementAt("input[type=button]", 1).Click();
            AssertUI.AlertTextEquals(browser, "Confirmation 1");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.AlertTextEquals(browser, "Confirmation 2");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "2");

            // confirm third
            section.ElementAt("input[type=button]", 2).Click();
            Assert.IsFalse(browser.HasAlert());
            browser.Wait();
            AssertUI.InnerTextEquals(index, "3");

            // confirm fourth
            section.ElementAt("input[type=button]", 3).Click();
            AssertUI.AlertTextEquals(browser, "Generated 1");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "4");

            // confirm fifth
            section.ElementAt("input[type=button]", 4).Click();
            AssertUI.AlertTextEquals(browser, "Generated 2");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "5");

            // confirm conditional
            section.ElementAt("input[type=button]", 5).Click();
            Assert.IsFalse(browser.HasAlert());
            browser.Wait();
            AssertUI.InnerTextEquals(index, "6");

            browser.First("input[type=checkbox]").Click();

            section.ElementAt("input[type=button]", 5).Click();
            AssertUI.AlertTextEquals(browser, "Conditional 1");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "6");

            browser.First("input[type=checkbox]").Click();

            section.ElementAt("input[type=button]", 5).Click();
            Assert.IsFalse(browser.HasAlert());
            browser.Wait();
            AssertUI.InnerTextEquals(index, "6");

            browser.First("input[type=checkbox]").Click();

            section.ElementAt("input[type=button]", 5).Click();
            AssertUI.AlertTextEquals(browser, "Conditional 1");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "6");

            //localization - resource binding in confirm postback handler message

            section.ElementAt("input[type=button]", 6).Click();
            AssertUI.AlertTextEquals(browser, "EnglishValue");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "7");

            browser.First("#ChangeLanguageCZ").Click();

            browser.WaitFor(() => {
                index = browser.First("[data-ui=\"command-index\"]");
                AssertUI.InnerTextEquals(index, "0");
            }, 1500, "Redirect to CZ localization failed.");

            section = browser.First(sectionSelector);

            //ChangeLanguageEN
            section.ElementAt("input[type=button]", 6).Click();
            AssertUI.AlertTextEquals(browser, "CzechValue");
            browser.DismissAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "0");

            section.ElementAt("input[type=button]", 6).Click();
            AssertUI.AlertTextEquals(browser, "CzechValue");
            browser.ConfirmAlert();
            browser.Wait();
            AssertUI.InnerTextEquals(index, "7");
        }