Code Mamba

Code snippets

Using variables from the global JS scope with selenium IDE

without comments

To use a variable from your page you need a reference to the current window. This is how to refer the current window:

this.browserbot.getUserWindow();

For example:

echo javascript{this.browserbot.getUserWindow().test}

will result:

[info] echo: TEST_VARIABLE_GOES_HERE

where your sourcecode is:

<script type="text/javascript">
    var test = 'TEST_VARIABLE_GOES_HERE';
</script>

Written by Wyand

September 17th, 2011 at 12:15 pm

Posted in JavaScript,Other,Selenium

Tagged with ,

Leave a Reply