Rohhit
Rohhit

Reputation: 742

Hint text testing using selenium IDE

I am learning selenium IDE.

For learning and testing, I have chosen popular social wbsite's 'Sign Up' page.

enter image description here

On this page we can see several textfields with hint text.(e.g : First name).

I want to Assert/verify this text if it is 'present or not' in that perticular text field.

For that I have written following script:

assertTextPresent |   //*[@id='.....'] |  First name
assertText        |   //*[@id='.....'] |  First name
verifyTextPresent |   //*[@id='.....'] |  First name
verifyText        |   //*[@id='.....'] |  First name

But every time when i execute the script, i get result like this :

[info] Executing: |assertTextPresent | //*[@id='u_0_1'] | First name |
[error] false 

[info] Executing: |assertText | //*[@id='u_0_1'] | First name |
[error] Actual value '' did not match 'First name' 

[info] Executing: |verifyTextPresent | //*[@id='u_0_1'] | First name |

[info] Executing: |verifyText | //*[@id='u_0_1'] | First name | 

So can anybody suggest me the correct script for testing 'Hint text' ?

Upvotes: 0

Views: 1490

Answers (2)

Jsmith2800
Jsmith2800

Reputation: 1113

You need to find the element that the hint text is defined in. for example, the search field on this site has the hint text of 'search', and the code for that is:

<form id="search" autocomplete="off" method="get" action="/search">
<input type="text" maxlength="240" autocomplete="off" tabindex="1" 
value="" placeholder="search" name="q" style="display: inline-block; 
width: 188px; max-width: 188px;">
</form>

so it's the 'placeholder' attribute which contains the text, so what you can do is:

<tr>
<td>verifyAttribute</td>
<td>name=q@placeholder</td>
<td>search</td>
</tr>

you just need to substitute the locator/attribute name in the Target field with what you're testing, and then the value with what it should be.

Upvotes: 2

Klendathu
Klendathu

Reputation: 793

If you're using the IDE and right-click on that text in the field, it's not actually there. Use Inspect element and you'll find it's "hidden".

Upvotes: 0

Related Questions