Lav*_*kar 11 java selenium selenium-webdriver
在webdriver中,如何要求webdriver等到文本字段中存在文本.
实际上我有一个kendo文本字段,其值来自数据库,需要一些时间来加载.一旦加载我就可以继续了.
请帮忙
Dak*_*rra 16
您可以使用WebDriverWait.从docs示例:
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(...).getText().length() != 0;
}
});
Run Code Online (Sandbox Code Playgroud)
您可以使用WebDriverWait.从docs示例:
上面的ans使用.getTex()这不是从输入字段返回文本
使用.getAttribute("value")而不是getText()
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(...).getAttribute("value").length() != 0;
}
});
Run Code Online (Sandbox Code Playgroud)
测试100%工作希望这将有所帮助
小智 6
使用WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)和ExpectedCondition (org.openqa.selenium.support.ui.ExpectedConditions)对象
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("element_id"), "The Text"));
Run Code Online (Sandbox Code Playgroud)
一个工作和使用lambda功能的衬垫.
wait.until((ExpectedCondition<Boolean>) driver -> driver.findElement(By.id("elementId")).getAttribute("value").length() != 0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
41271 次 |
| 最近记录: |