Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to test validation messages are showing in Blazor website?

$
0
0

I'm writing integration tests using WebDriver against a Blazor Web App. How do I test the visibility of validation messages?

For example, I have the following form:

<form method="post" action="/users/register"><div><input id="Name" class="form-control valid" type="text" aria-required="true" /><label for="Name" class="form-label">Name</label><ValidationMessage For="Name" class="text-danger"/></div><div><input id="EmailAddress" class="form-control valid" aria-required="true" type="email" /><label for="EmailAddress" class="form-label">Email Address</label></div></form>

And the following test using WebDriver.

webDriver.Navigate().GoToUrl(WebSite.FullUrl(url))var name = webDriver.FindElement(By.Id("Name"))name.Clear();var emailAddress = webDriver.FindElement(By.Id("EmailAddress"))

At this point I can see the validation message is now visible as expected. How do I programmatically verify that the validation message is visible?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>