Add Variables to the User-Extensions.js file

This article shows you how to add variables to the user-extensions.js file for use in your tests. You have to declare a function first, then call that function in your test to access the varaibles.This method can be used in both the IDE and RC versions of the user-extension file.

So, open your user-extensions.js file and add the following:

Selenium.prototype.doLoadParameters = function()
{
storedVars["machine"] = "W7M-134766";
storedVars["whoAmI"] = "RC";
}; 

How to store time

Here is an example of how to store the Unix Epoch time for any number of reasons:

storeEval | new Date().getTime(); | currentTime

You can you this to:

  • Time page loads
  • Get a unique non-repeatable number (unique ID)
  • Get the current time

Another example for use with a formatted date:

storeEval | var d=new Date(); ((d.getMonth()+1))+'-'+d.getDate()+'-'+d.getFullYear(); | formattedDate

Will return: MM-DD-YYYY

Another example showing date and time:

Tags: 

How to create popup boxes that require manual input

Here is how you can create three different input boxes in your script that require manual input for the script to proceed further:

storeeval | alert("This is alert box")                           |
storeeval | prompt("This is prompt box. Please enter the value") | text
storeeval | confirm("this is cofirm box")   |

This might be a good way to delay an RC script from completing, and tearing down the browser window because it would require a user to provide manual input before the script continues to the next command.

Tags: 

Selenium Documentation and User Extensions

Many of us continue to use Selenium IDE and its stable working extensions. However, since the openqa site was removed/closed, there really isnt a repository of those extensions for us to go to. You could use this site, and even contribute to it to help the rest of us out, or you could try to access the old site using the Internet Time Machine (which allows us to go back in time to websites and snapshots of their content). Here is the address to start browsing that old site:

Tags: 

Pages