Verify that the input text element is not empty in the Selenium IDE

How to check that an input element has any text in it. It is loaded with random text, so I can’t check the specific value, but there must be text in it. I am using Selenium IDE

+4
source share
5 answers

In the Selenium IDE, you can use the verifyEval command and a bit of JavaScript to verify that the field is filled or not.

 Command: verifyEval Target: this.page().findElement("//input[@id='email']").value != '' Value: true 

In this case, I test that <input type="email" id="email" value=' address@domain.com "> not an empty field on my HTML page.

When this command is run, the JavaScript code in the target is evaluated. Here it checks the current value of the email field on an empty string. If they do not match (for example, the field is not empty), true returned. This return value is then compared with the expected Value , which is also true, and so the test passes.

+5
source

I just use

 verifyNotValue|//input[@id='email']| 

third parameter is empty

+3
source

This should be cinch if you use Selenium-RC with any programming language. However, given that you are using an IDE, I would recommend adding this user extension. This will give you some loop designs. You can use storeText and then make a decision based on the value of the variable in which the saved text is stored. Saved Vars is another useful firefox IDE extension for parsing the contents of the storeText variable.

0
source

Try the following:

driver.find_element_by_id ("email"). get_attribute ("value")! = ''

0
source

This was part of the approval of the registration form. The firstName field was supplied with data. Then I used the following code to check if the field was filled with data.

 if(driver.findElement(By.cssSelector("#FirstName")).getText()==""){ System.out.println("field didn't fillup with data"); } else { System.out.println("field filled up with data"); } 
0
source

All Articles