Esempio n. 1
0
        public void CanSelectTabs()
        {
            var paragraph = Browser.FindElement(By.Id("basic-tabs"));
            var links     = paragraph.FindElements(By.TagName("a"));
            var content   = paragraph.FindElement(By.ClassName("tab-content"));
            var panels    = content.FindElements(By.TagName("div"));

            Assert.NotEmpty(links);
            Assert.NotEmpty(panels);

            WaitAssert.False(() => links[0].GetAttribute("class").Contains("show"));
            WaitAssert.True(() => links[1].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => links[2].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => panels[0].GetAttribute("class").Contains("show"));
            WaitAssert.True(() => panels[1].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => panels[2].GetAttribute("class").Contains("show"));

            links[0].Click();
            WaitAssert.True(() => links[0].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => links[1].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => links[2].GetAttribute("class").Contains("show"));
            WaitAssert.True(() => panels[0].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => panels[1].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => panels[2].GetAttribute("class").Contains("show"));

            links[2].Click();
            WaitAssert.False(() => links[0].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => links[1].GetAttribute("class").Contains("show"));
            WaitAssert.True(() => links[2].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => panels[0].GetAttribute("class").Contains("show"));
            WaitAssert.False(() => panels[1].GetAttribute("class").Contains("show"));
            WaitAssert.True(() => panels[2].GetAttribute("class").Contains("show"));
        }
Esempio n. 2
0
        public void CanWireUpINotifyPropertyChangedToEditContext()
        {
            var appElement        = MountTestComponent <NotifyPropertyChangedValidationComponent>();
            var userNameInput     = appElement.FindElement(By.ClassName("user-name")).FindElement(By.TagName("input"));
            var acceptsTermsInput = appElement.FindElement(By.ClassName("accepts-terms")).FindElement(By.TagName("input"));
            var submitButton      = appElement.FindElement(By.TagName("button"));
            var messagesAccessor  = CreateValidationMessagesAccessor(appElement);
            var submissionStatus  = appElement.FindElement(By.Id("submission-status"));

            // Editing a field triggers validation immediately
            WaitAssert.Equal("valid", () => userNameInput.GetAttribute("class"));
            userNameInput.SendKeys("Too long too long\t");
            WaitAssert.Equal("modified invalid", () => userNameInput.GetAttribute("class"));
            WaitAssert.Equal(new[] { "That name is too long" }, messagesAccessor);

            // Submitting the form validates remaining fields
            submitButton.Click();
            WaitAssert.Equal(new[] { "That name is too long", "You must accept the terms" }, messagesAccessor);
            WaitAssert.Equal("modified invalid", () => userNameInput.GetAttribute("class"));
            WaitAssert.Equal("invalid", () => acceptsTermsInput.GetAttribute("class"));

            // Can make fields valid
            userNameInput.Clear();
            userNameInput.SendKeys("Bert\t");
            WaitAssert.Equal("modified valid", () => userNameInput.GetAttribute("class"));
            acceptsTermsInput.Click();
            WaitAssert.Equal("modified valid", () => acceptsTermsInput.GetAttribute("class"));
            WaitAssert.Equal(string.Empty, () => submissionStatus.Text);
            submitButton.Click();
            WaitAssert.True(() => submissionStatus.Text.StartsWith("Submitted"));

            // Fields can revert to unmodified
            WaitAssert.Equal("valid", () => userNameInput.GetAttribute("class"));
            WaitAssert.Equal("valid", () => acceptsTermsInput.GetAttribute("class"));
        }
Esempio n. 3
0
        public void BenchmarksRunWithoutError()
        {
            // In CI, we only verify that the benchmarks run without throwing any
            // errors. To get actual perf numbers, you must run the E2EPerformance
            // site manually.
            var verifyOnlyLabel = Browser.FindElement(By.XPath("//label[contains(text(), 'Verify only')]/input"));

            verifyOnlyLabel.Click();

            var runAllButton = Browser.FindElement(By.CssSelector("button.btn-success.run-button"));

            runAllButton.Click();

            // The "run" button goes away while the benchmarks execute, then it comes back
            WaitAssert.False(() => runAllButton.Displayed);
            WaitAssert.True(
                () => runAllButton.Displayed || Browser.FindElements(By.CssSelector(".benchmark-error")).Any(),
                TimeSpan.FromSeconds(60));

            var finishedBenchmarks = Browser.FindElements(By.CssSelector(".benchmark-idle"));
            var failedBenchmarks   = Browser.FindElements(By.CssSelector(".benchmark-error"));

            Assert.NotEmpty(finishedBenchmarks);
            Assert.Empty(failedBenchmarks);
        }
Esempio n. 4
0
        public void CanValidateStringWithEvent_InitiallySelected()
        {
            var paragraph = Browser.FindElement(By.Id("validate-string-with-event-initially-selected"));
            var select    = new SelectElement(paragraph.FindElement(By.TagName("select")));

            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(1);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(0);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 5
0
        public void CanValidateEnumWithBind_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-enum-with-bind-initially-blank"));
            var select    = new SelectElement(paragraph.FindElement(By.TagName("select")));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(1);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(0);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
        public void CanValidateTextWithEvent_InitiallyPopulated()
        {
            var paragraph = Browser.FindElement(By.Id("validate-text-with-event-initially-populated"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys(Keys.Backspace);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("b");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
        public void CanValidateTextWithBind_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-text-with-bind-initially-blank"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("a");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys(Keys.Backspace);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
        public void CanValidateNumericWithEvent_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-numeric-with-event-initially-blank"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("1");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys(Keys.Backspace);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 9
0
        public void CanNavigateProgrammatically()
        {
            SetUrlViaPushState("/");

            var app          = MountTestComponent <TestRouter>();
            var testSelector = WaitUntilTestSelectorReady();

            app.FindElement(By.Id("do-navigation")).Click();
            WaitAssert.True(() => Browser.Url.EndsWith("/Other"));
            WaitAssert.Equal("This is another page.", () => app.FindElement(By.Id("test-info")).Text);
            AssertHighlightedLinks("Other", "Other with base-relative URL (matches all)");

            // Because this was client-side navigation, we didn't lose the state in the test selector
            Assert.Equal(typeof(TestRouter).FullName, testSelector.SelectedOption.GetAttribute("value"));
        }
Esempio n. 10
0
        public void CanNavigateProgrammaticallyWithForceLoad()
        {
            SetUrlViaPushState("/");

            var app          = MountTestComponent <TestRouter>();
            var testSelector = WaitUntilTestSelectorReady();

            app.FindElement(By.Id("do-navigation-forced")).Click();
            WaitAssert.True(() => Browser.Url.EndsWith("/Other"));

            // Because this was a full-page load, our element references should no longer be valid
            Assert.Throws <StaleElementReferenceException>(() =>
            {
                testSelector.SelectedOption.GetAttribute("value");
            });
        }
Esempio n. 11
0
        public void CanBindCheckbox_InitiallyChecked()
        {
            var target       = Browser.FindElement(By.Id("checkbox-initially-checked"));
            var boundValue   = Browser.FindElement(By.Id("checkbox-initially-checked-value"));
            var invertButton = Browser.FindElement(By.Id("checkbox-initially-checked-invert"));

            Assert.True(target.Selected);
            Assert.Equal("True", boundValue.Text);

            // Modify target; verify value is updated
            target.Click();
            WaitAssert.False(() => target.Selected);
            WaitAssert.Equal("False", () => boundValue.Text);

            // Modify data; verify checkbox is updated
            invertButton.Click();
            WaitAssert.True(() => target.Selected);
            WaitAssert.Equal("True", () => boundValue.Text);
        }
Esempio n. 12
0
        public void CanValidateMultiString_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-multi-string-initially-blank"));
            var select    = new SelectElement(paragraph.FindElement(By.TagName("select")));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(1);
            select.SelectByIndex(2);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.DeselectByIndex(1);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.DeselectByIndex(2);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(0);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }