Blazor: Start with the client instead of index.html

asp.net-core blazor c# nunit selenium-webdriver

Question

I am trying to test my Blazor app using selenium with Nunit. But the problem is I cannot run my use cases because of the starting page is index.html. Tests don't wait for redirecting and they always fail for this reason. Is there any way to eliminate the index.html and run my tests.

Accepted Answer

With Selenium you can wait for a specific element to be present, so just wait for the app tag to be visible?

See here and here for examples.

They boil down to:

WebDriverWait wait = new WebDriverWait(webDriver, 10); //seconds wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("foo)));

Or see the Selenium documentation about it: https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp


Popular Answer

No, there must be a starting page which holds the first <app></app> tag.

But your should be able to test with selenium, because the Blazor team does this also. See https://github.com/aspnet/Blazor/tree/master/test

and post a new question on the problems you encounter with Selenium.

Btw: I'm using testcafe for my Blazor app which I find way better then Selenium.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why