Scala 如何使用Selenium WebDriverWait获得更有意义的失败消息/断言?
当等待条件超时时,我收到了非常无用的消息:Scala 如何使用Selenium WebDriverWait获得更有意义的失败消息/断言?,scala,testing,selenium,webdriver,qa,Scala,Testing,Selenium,Webdriver,Qa,当等待条件超时时,我收到了非常无用的消息: Tests in error: myTestName(mySuiteName): Timed out after 10 seconds waiting for com.mycompany.qa.core.SeleniumWebTesting$$anon$1@6818c458 下面是Scala的代码: def pageContains(locatorType: String, content: Stri
Tests in error:
myTestName(mySuiteName): Timed out after 10 seconds waiting for
com.mycompany.qa.core.SeleniumWebTesting$$anon$1@6818c458
下面是Scala的代码:
def pageContains(locatorType: String, content: String) {
locatorType match {
case "TagName" =>
val tag = new WebDriverWait(driver, defaultWait).until(
new ExpectedCondition[Boolean] {
// it times out on this line below, but I can't send out any assert failure or useful message
override def apply(driver: WebDriver) = driver.findElement(By.tagName(content)).isDisplayed
}
)
case _ =>
throw new UnsupportedOperationException("No valid locator strategy received (try a valid one, like class name)")
}
}
您可以使用withMessage()方法
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.withMessage("Your desired Message");
wait.until(new ExpectedConditions(boolean));
您可以使用withMessage()方法
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.withMessage("Your desired Message");
wait.until(new ExpectedConditions(boolean));
如果您使用的是scala,我们在这方面取得了巨大成功如果您使用的是scala,我们在这方面取得了巨大成功