How to Check Actual Values of Stored Variables in a Selenium IDE Test

Automated test scripts often revolve around targeting a certain page element and checking whether it’s value is correct, according to what is expected (based on business rules). Below is a simple test, here I am trying to check whether the highlighted text displayed in Gmail’s login page (‘Sign in to continue to Gmail’) is correct

GoogleTest1

This is the format I usually follow in writing verification/assertion tests

In the example, I stored the actual and expected text values in separate variables, different names from each other, because I may end up using them in other test cases. This way, I can also write the verify (or assert) statement in a simple to understand manner, by using a comparison statement, storedVars[‘variable1’] == storedVars[‘variable2’], which just means that I am comparing the correct value (variable1) to the retrieved page element value (variable2).

And then I run the test.

GoogleTest2

..which do not always end up working properly, as seen in the above screenshot. Why did my test fail? How come the verify statement is highlighted red? As far as I can see, the correct value that I stored in variable1 has the same value as the one being displayed in the page. So why is there an error in my test?

Let’s see if the Stored-Vars tab in the Selenium IDE can give us a hint.

GoogleTest3

Oh! Now I see what’s causing the error! It seems that the expected value stored in variable1 has an extra space in the end. Maybe I accidentally added an extra space while typing. Silly me. 😀

Let’s remove that space and run the test again, shall we?

GoogleTest4

That’s better. Our verify statement is now highlighted green. 🙂

Of course, if an error occurs in the test script and there is nothing wrong in the expected value, it means that there is a problem with the actual value being retrieved from the page. You can see that using the same Stored-Vars tab in the IDE.

P.S. The Stored-Vars tab does not come together with the basic installed Selenium IDE. It is a plugin, created by Samit Badle and can be downloaded from the following link: Stored Variables Viewer (Selenium IDE) by Samit Badle

Happy testing! :3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s