Learning Resources
Browser and variable access by JavaScript
Storing variables in Selenium IDE
Selenium functions store, storeValue, and storeText store some data for later access.
Selenium uses a map called storedVars to store the data.
You can store strings. Example:
store
this text is a string
variable1
You can use previously stored variables. ${varaiable_name} gives us access to the storedVars map. Example:
store
${variable1} okay?
variable2
* varaible2 will now be ‘this text is a string okay?’
You can use pure javascript expressions. With javascript{} we can use pure javascript:
store
javascript{Math.random()}
random_variable
So you can access the storedVars map directly in a javascript expression:
store
javascript{storedVars['random_variable']}
random_variable_copy
Storing variables in Selenium IDE
* random_variable and random_variable_copy should be exactly the same.
Note that if you use:
store 0 zero
zero will be 0, but casted as a string. So later if you use for example:
javascript{storedVars['zero']+1}
You will get ’01′ instead of ’1′.
So when you need 0 as an integer you should store your variables using javascript:
getEval storedVars['zero'] = 0;
* getEval gets the result of evaluating the specified JavaScript snippet.