-
+ @if (UseExperimentalValidator)
+ {
+
+ }
+ else
+ {
+
+ }
User name:
@@ -29,6 +36,8 @@
}
@code {
+ protected virtual bool UseExperimentalValidator => false;
+
string lastCallback;
[Required(ErrorMessage = "Please choose a username")]
diff --git a/src/Components/test/testassets/BasicTestApp/FormsTest/SimpleValidationComponentUsingExperimentalValidator.cs b/src/Components/test/testassets/BasicTestApp/FormsTest/SimpleValidationComponentUsingExperimentalValidator.cs
new file mode 100644
index 0000000000..90484aad05
--- /dev/null
+++ b/src/Components/test/testassets/BasicTestApp/FormsTest/SimpleValidationComponentUsingExperimentalValidator.cs
@@ -0,0 +1,7 @@
+namespace BasicTestApp.FormsTest
+{
+ public class TypicalValidationComponentUsingExperimentalValidator : TypicalValidationComponent
+ {
+ protected override bool UseExperimentalValidator => true;
+ }
+}
diff --git a/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponent.razor b/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponent.razor
index 1bd3b748d1..90b2f6a26b 100644
--- a/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponent.razor
+++ b/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponent.razor
@@ -2,7 +2,14 @@
@using Microsoft.AspNetCore.Components.Forms
+ @if (UseExperimentalValidator)
+ {
+
+ }
+ else
+ {
+ }
Name:
@@ -11,6 +18,10 @@
Email:
+
+ Email:
+
+
Age (years):
@@ -49,12 +60,18 @@
+
+
+
+
@foreach (var entry in submissionLog) { - @entry
}
@code {
+ protected virtual bool UseExperimentalValidator => false;
+
Person person = new Person();
EditContext editContext;
ValidationMessageStore customValidationMessageStore;
@@ -75,6 +92,9 @@
[StringLength(10, ErrorMessage = "We only accept very short email addresses (max 10 chars)")]
public string Email { get; set; }
+ [Compare(nameof(Email), ErrorMessage = "Email and confirm email do not match.")]
+ public string ConfirmEmail { get; set; }
+
[Range(0, 200, ErrorMessage = "Nobody is that old")]
public int AgeInYears { get; set; }
diff --git a/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponentUsingExperimentalValidator.cs b/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponentUsingExperimentalValidator.cs
new file mode 100644
index 0000000000..9ede005a8a
--- /dev/null
+++ b/src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponentUsingExperimentalValidator.cs
@@ -0,0 +1,7 @@
+namespace BasicTestApp.FormsTest
+{
+ public class SimpleValidationComponentUsingExperimentalValidator : SimpleValidationComponent
+ {
+ protected override bool UseExperimentalValidator => true;
+ }
+}
diff --git a/src/Components/test/testassets/BasicTestApp/Index.razor b/src/Components/test/testassets/BasicTestApp/Index.razor
index fe94ad595e..f836fa6c39 100644
--- a/src/Components/test/testassets/BasicTestApp/Index.razor
+++ b/src/Components/test/testassets/BasicTestApp/Index.razor
@@ -29,7 +29,10 @@
+
+
+
diff --git a/src/Shared/E2ETesting/BrowserAssertFailedException.cs b/src/Shared/E2ETesting/BrowserAssertFailedException.cs
index 007db0ac79..08d04a912d 100644
--- a/src/Shared/E2ETesting/BrowserAssertFailedException.cs
+++ b/src/Shared/E2ETesting/BrowserAssertFailedException.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Text;
using Xunit.Sdk;
namespace OpenQA.Selenium
@@ -13,15 +14,31 @@ namespace OpenQA.Selenium
// case.
public class BrowserAssertFailedException : XunitException
{
- public BrowserAssertFailedException(IReadOnlyList logs, Exception innerException, string screenShotPath)
- : base(BuildMessage(innerException, logs, screenShotPath), innerException)
+ public BrowserAssertFailedException(IReadOnlyList logs, Exception innerException, string screenShotPath, string innerHTML)
+ : base(BuildMessage(innerException, logs, screenShotPath, innerHTML), innerException)
{
}
- private static string BuildMessage(Exception innerException, IReadOnlyList logs, string screenShotPath) =>
- innerException.ToString() + Environment.NewLine +
- (File.Exists(screenShotPath) ? $"Screen shot captured at '{screenShotPath}'" + Environment.NewLine : "") +
- (logs.Count > 0 ? "Encountered browser logs" : "No browser logs found") + " while running the assertion." + Environment.NewLine +
- string.Join(Environment.NewLine, logs);
+ private static string BuildMessage(Exception exception, IReadOnlyList logs, string screenShotPath, string innerHTML)
+ {
+ var builder = new StringBuilder();
+ builder.AppendLine(exception.ToString());
+
+ if (File.Exists(screenShotPath))
+ {
+ builder.AppendLine($"Screen shot captured at '{screenShotPath}'");
+ }
+
+ if (logs.Count > 0)
+ {
+ builder.AppendLine("Encountered browser errors")
+ .AppendJoin(Environment.NewLine, logs);
+ }
+
+ builder.AppendLine("Page content:")
+ .AppendLine(innerHTML);
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/Shared/E2ETesting/WaitAssert.cs b/src/Shared/E2ETesting/WaitAssert.cs
index 4ef1446191..8792d2692f 100644
--- a/src/Shared/E2ETesting/WaitAssert.cs
+++ b/src/Shared/E2ETesting/WaitAssert.cs
@@ -101,6 +101,8 @@ namespace Microsoft.AspNetCore.E2ETesting
// tests running concurrently might use the DefaultTimeout in their current assertion, which is fine.
TestRunFailed = true;
+ var innerHtml = driver.FindElement(By.CssSelector(":first-child")).GetAttribute("innerHTML");
+
var fileId = $"{Guid.NewGuid():N}.png";
var screenShotPath = Path.Combine(Path.GetFullPath(E2ETestOptions.Instance.ScreenShotsPath), fileId);
var errors = driver.GetBrowserLogs(LogLevel.All);
@@ -109,7 +111,7 @@ namespace Microsoft.AspNetCore.E2ETesting
var exceptionInfo = lastException != null ? ExceptionDispatchInfo.Capture(lastException) :
CaptureException(() => assertion());
- throw new BrowserAssertFailedException(errors, exceptionInfo.SourceException, screenShotPath);
+ throw new BrowserAssertFailedException(errors, exceptionInfo.SourceException, screenShotPath, innerHtml);
}
return result;