Java – how do I check if a field is empty and how do I read the entered text?

How to check whether the text field is empty, that is, if how to store the text in the variable is given, no input is given?

Solution

The access value attribute of < input > is a web page element Here is an example:

WebElement input@R_626_2419@ = driver.findElement(By.id("input@R_626_2419@Id"));
String textInsideInput@R_626_2419@ = input@R_626_2419@.getAttribute("value");

// Check whether input field is blank
if(textInsideInput@R_626_2419@.isEmpty())
{
   System.out.println("Input field is empty");
}

Hope to help you!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>