Web元素的访问值属性<input>.以下是一个例子:
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");
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你!
WebElement ele = driver.findElement(by locator)); //find the text field
if (ele.getAttribute("value").isEmpty()) {
//Do something if the text field is empty
}
else {
//Store the value
String store=ele.getAttribute("value");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39249 次 |
| 最近记录: |