1
votes

I have a login page. There are textboxes for username and password.

If you click login button when you don't enter username and password, a span shows as "Invalid login".

If you just enter username, a span shows "Enter password"

If you just enter password, a span shows "Enter username"

<span class="field-validation-error" data-valmsg-for="ErrMsg" data-valmsg-replace="true">Invalid login</span>

<span class="field-validation-error" data-valmsg-for="ErrMsg" data-valmsg-replace="true">Enter password</span>

<span class="field-validation-error" data-valmsg-for="ErrMsg" data-valmsg-replace="true">Enter username</span>

How can i test these errors on Selenium IDE? Is it possible?

1

1 Answers

3
votes

Your test will be like this (replace button and fields locators to actual ones):

click | id=login
assertElementPresent | css=span:contains('Invalid login')
type | id=name | correctName
click | id=login
assertElementPresent | css=span:contains('Enter password')
type | id=name | 
type | id=pass | correctPass
assertElementPresent | css=span:contains('Enter username')

This code will work with assumption that client validation responsible for all these warnings (and I think it is so). Otherwise it will be useful to add waitForElementPresent | css=span:contains('warning_string') before assertions. Also both fields should be empty before first click step.