【问题标题】:Blazor: Start with the client instead of index.htmlBlazor:从客户端而不是 index.html 开始
【发布时间】:2023-03-23 09:45:01
【问题描述】:

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

【问题讨论】:

    标签: c# selenium-webdriver asp.net-core nunit blazor


    【解决方案1】:

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

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

    并就您在使用 Selenium 时遇到的问题发布一个新问题。

    顺便说一句:我将testcafe 用于我的 Blazor 应用程序,我发现它比 Selenium 更好。

    【讨论】:

      【解决方案2】:

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

      有关示例,请参阅 herehere

      他们归结为:

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

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

      【讨论】:

      • 这就是我要找的。刚刚拯救了我的一天!谢谢!
      猜你喜欢
      • 1970-01-01
      • 2021-06-06
      • 2020-10-27
      • 1970-01-01
      • 2019-11-30
      • 2019-10-09
      • 2020-05-24
      • 1970-01-01
      • 2020-08-27
      相关资源
      最近更新 更多