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.

Leave a comment

Your email address will not be published. Required fields are marked *

7 thoughts on “Using variables with Selenium IDE

  • Senthil

    Will this storeattribute work if the dynamc value that I need to store is along with a text like:

    Result Screen looks like this

    Confirmation screen:
    The account is created.
    Acc No:123456

    I need to capture he account id from the above and use it another test case.

    Pleas elet me know.

  • NJK

    I found that the “store” command in SeleniumIDE is a string. This makes it “impossible” to do basic maths with the variable.

    eg. javascript:if{if(storedVars[‘X’] ) {storedVars[‘Y’] += 1;}}
    The results will become “Y1111…”

    Is there a way to store the variable as a int or a real?

    • Elaphe_cz

      You need to make int from it by using function, that is defined only for int (or real)

      so, if you have “10” in variable …

      variable + 1 .... is "101", but
      (variable-0)+1... is "11" ... because expr in () is now int.
      (variable-0.0)+1 should be real i.e. "11.0" , but i've not tried it.

      You can also use storedVars['x'] -= -1, because “-” is not defined function for string.

  • Ernest

    I am using Hudson to run my test cases made on selenium IDE.
    I am using “store” commad to define parameters for the tests.

    Network Contact Group

    And the replacement of the parameter in the page element is like this:


    when I run this directly from the selenium ide, it works fine.
    But when I run the test from a hudson build, I get the following error:
    Option with label ‘${groupType}’ not found.

    And this error only happens with select elements (combo)
    If the element is a textbox tehre is no problem.

    It seams like Running from hudson, the varable replacement doesn’t work.

    Any hepl please!


  • Korbinian Wackershofer

    It would be great to see an example how an element from a web-page is stored into a selenium variable using selenium ID. Possibly with an IDE screenshot to illustrate usage.