Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify input text element is not empty in Selenium IDE

How can I verify that an input element has any text in it. It is loaded with random text so I can't verify a specific value, but there must be some text in it. I'm using Selenium IDE

like image 934
Maurizio Pozzobon Avatar asked Feb 23 '23 23:02

Maurizio Pozzobon


1 Answers

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

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

In this case, I'm testing that the <input type="email" id="email" value='[email protected]"> is not an empty field on my HTML page.

When this command is run, the JavaScript code in the target is evaluated. Here it is testing the current value of the email field against an empty string. If they don't match (e.g. the field isn't empty) then it true is returned. This return value is then compared to the expected Value which is also true and so the test passes.

like image 171
Jeffrey D. Hoffman Avatar answered Feb 26 '23 13:02

Jeffrey D. Hoffman