硒测试有时会在天蓝色管道中失败并在本地通过

Gkm*_*Gkm 5 selenium timeoutexception selenium-webdriver azure-devops azure-pipelines

单击按钮后未找到链接或任何验证消息,测试用例就会失败。

我使用显式等待页面加载:

var waitForDocumentReady = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
            waitForDocumentReady.Until((wdriver) => (WebDriver as IJavaScriptExecutor).ExecuteScript("return document.readyState").Equals("complete"));
Run Code Online (Sandbox Code Playgroud)

对于等待验证消息的特定 div:

 WebDriverWait wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10));
            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.ClassName("validationErrors")));
Run Code Online (Sandbox Code Playgroud)

但测试用例有时会通过管道,有时会失败。

Deb*_*anB 0

您需要注意以下几点: