Selenium


Using variables with Selenium IDE 7

The “store” commands embedded into Selenium IDE are very useful when working with dynamic content.  “store” allows you to specify a variable and it’s value for use later on in your testing suite.  You can create a variable in one test case, then retrieve and use it in another.

I created a test case that creates a support ticket.  In all, I’ll need to create tests for creating the ticket, updating the ticket, and deleting the ticket.  All three can be upwards of 40-50 commands a piece once all the data verifications are included.  In order to keep test cases as small as possible, I’d store the new support ticket ID in a variable upon completion of the first test case that created the support ticket.

In this situation, the support ticket ID will be different every time, so “store”, which allows you to hardcode a variable value, will not work.  The command I used was “storeAttribute”, which allows you to locate an element, or it’s value, on a page using xPath and store it.  The target will use xpath “//input[@name=’newTicketId’]@value”, which selects the value of the input with name “newTicketId”.  The value will be your variable name, such as “newTicketId”.  To access this variable, references it like “${newTicketId}” in another command’s value.


Selenium IDE – How to follow links that open a new window 10

While building another test case, I ran into a situation that wasn’t working with the standard point and click navigation. Clicking on a dynamic link opened a new window where I needed to continue my test, but selenium didn’t follow the newly opened window. There are a few ways to do this, but what made this one difficult was that the link and new window was a dynamic url each time.
The fix was to store the link in a variable, then open the variable link with selenium using “open”. To store the variable I used “storeAttribute” and the target used xPath to grab the hyperlink’s href attribute from the url and save the variable as “ticketUrl” as in the image below: