Variables in Selenium IDE

You can store and later reuse values in Selenium IDE.

Storing values?

<tr>
<td>storeEval</td>
<td>window.document.domain</td>
<td>variableName</td>
</tr>

All store commands start with store. A few examples:

  • storeEval: Stores the value of a JavaScript snippet.
  • storeAttribute: Can store the value of an html attribute.
    Example
    If you have: <href id=”example-id”>Hello world</href>
    Then: StoreAttribute | link=Hello World@id | idVariable
    Will give: example-id
  • there are many more store commands actually! Intelli-senseĀ  in the IDE will certainly help you!

Getting/using values?

You can reuse your stored values with ${variableName}. If you want to just display it in the log use:

<tr>
<td>echo</td>
<td>${variableName}</td>
<td></td>
</tr>

One Reply to “Variables in Selenium IDE”

  1. Hi there, I enjoyed reading your article although I would like to know if I could get help with a specific issue I am having using the storeVal, maybe its the approach that is off?

    I need to know how to accomplish something but not sure how as I am new to selenium commands.

    I tried the following:

    storeEval
    javascript{window.document.getElementById(‘myDiv’);}
    myResult

    then
    gotoIf
    ${myResult} == false
    lblWhereToGoIfStyleDisplayIsNotVisible

    This does not give me what I want as I always have the div in my page, even if the style = display : none.

    What I need is to get the display property of the style of the div and check that value to see if == none to then jump to the lblWhereToGoIfStyleDisplayIsNotVisible label

    I was thinking I need to use storeAttribute or storeElementPresent but not sure how to implement properly to get result needed.

    Any help is appreciated, thanks in advance.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.