如何使用Selenium Web Driver检查某个字段是否没有值(null
)?
这是我到目前为止所做的:
WebDriverWait wait5 = new WebDriverWait(driver, 5);
wait5.until(ExpectedConditions.elementToBeClickable(By.name("chargeId")));
答案 0 :(得分:0)
WebDriverWait wait5 = new WebDriverWait(driver, 5);
WebElement charge = wait5.until(ExpectedConditions.elementToBeClickable(By.name("chargeId")));
boolean noChargeIdPresent = charge.getText().isEmpty();
这将告诉您该字段是否为空。
答案 1 :(得分:0)
WebDriverWait wait5 = new WebDriverWait(driver, 5);
wait5.until(ExpectedConditions.elementToBeClickable(By.name("chargeId")));
if(wait5.findElement(By.name("chargeId")).getText().length() == 0) {
// =========== DO WHAT YOU WANT IF EMPTY============
}
else {
//======== DO WHEN NOT EMPTY==================
}