Blazor:从客户端开始而不是 index.html

Blazor: Start with the client instead of index.html

我正在尝试使用 selenium 和 Nunit 测试我的 Blazor 应用程序。但问题是我无法 运行 我的用例,因为起始页是 index.html。测试不会等待重定向,因此它们总是会失败。有什么方法可以消除 index.html 和 运行 我的测试。

不,必须有一个包含第一个 <app></app> 标记的起始页。

但是您应该可以使用 selenium 进行测试,因为 Blazor 团队也这样做。参见 https://github.com/aspnet/Blazor/tree/master/test

和post关于您在使用 Selenium 时遇到的问题的新问题。

顺便说一句:我正在为我的 Blazor 应用程序使用 testcafe,我发现它比 Selenium 更好。

使用 Selenium,您可以等待特定元素出现,所以只需等待应用标签可见?

有关示例,请参阅 here and here

归结为:

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

或者查看有关它的 Selenium 文档:https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp