如何检查文本字段是否为空白,即如果给出如何将该文本存储到变量中,则没有给出输入?
最佳答案
访问 <input>
的 value 属性网络元素。下面是一个例子:
WebElement inputBox = driver.findElement(By.id("inputBoxId"));
String textInsideInputBox = inputBox.getAttribute("value");
// Check whether input field is blank
if(textInsideInputBox.isEmpty())
{
System.out.println("Input field is empty");
}
希望对您有所帮助!
关于java - 如何检查字段是否为空以及如何读取输入的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25499551/