Selenium IDE Commonly Used Commands (Part 2)

Last month, I’ve shared eight Selenium IDE commands that are often used in automated tests. Today, let’s add a few more to that list and learn several types of store.

  • store. Testing an application involves running a good number of different scenarios which checks some information over and over again to make sure they continue to be displayed correctly. This means we need to write these information more than once and edit them one by one when the requirements have changed. That can be tiring for someone who is already maintaining lots of tests. In order to debug tests easier and faster, it is good practice to create variables which we can reuse anywhere. This is how useful the store command is. In the example below, we are creating a variable called ‘companyName’ and storing a text value of ‘DirectWithHotels’ to it. To use the variable in our tests, we just call it by using ${variableName} (the sample command echo ${companyName} thus shows us a result of ‘DirectWithHotels’).

store

  • storeText. Often the values we want to store in variables and manipulate are found in pages themselves, most of them are text or copies. We use storeText to retrieve them on their exact page locations. In our example below, we are trying to get the ‘Due Now – Prepayment’ amount being displayed in the page.

storeText

  • storeValue. For some web applications, storeText does not properly retrieve the information we see on the page, even if we specify the correct element location. For such occasions, try using storeValue. In the sample screenshot below, we are trying to get the ‘Total room cost’ value. storeText returned us a null value while storeValue retrieves the correct information.

storeValue

  • storeAttribute. Some information are not displayed on the page as text but rather are embedded into elements are attributes. Image alternate texts or source is one example. Element style data is another. These information can be retrieved using the storeAttribute command.

storeAttribute

  • storeEval. For computations or manipulations involving variables or pre-defined javascript objects or methods, the storeEval command is handy. In the example below, I wanted to get the current date (at the time of test) by storing the result of the javascript Date object and store it in a variable called ‘checkinDate’.

storeEval

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