I am trying to take a variable that is in Selenium and assign it to a javascript variable. I am aware of the storedVars[] associative array. I can echo the Selenium variables. But I simply want to assign the Selenium variable INTO a javascript variable. When doing so, I get the error "ReferenceError: storedVars is not defined". Is storedVars only recognized by Selenium and not javascript? Below is code of what I'm trying to do. I just want to console.log the javascript variable to show that I've assigned the variable.
<tr>
<td>open</td>
<td>http://google.com</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Advertising</td>
<td></td>
</tr>
<tr>
<td>storeTitle</td>
<td>title_se</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${title_se}</td>
<td></td>
</tr>
<tr>
<td>runScript</td>
<td>var title_main = storedVars['title_se'];</td>
<td></td>
</tr>
<tr>
<td>runScript</td>
<td>console.log("The stored page title is " + title_main);</td>
<td></td>
</tr>
There was no error in your script and it was executed without any error.
Following worked with Selenium IDE 2.9.1
<tr>
<td>open</td>
<td>http://google.com</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Advertising</td>
<td></td>
</tr>
<tr>
<td>storeTitle</td>
<td>title_main</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>var title_uc=storedVars["title_main"].toUpperCase();title_uc</td>
<td>uc</td>
</tr>
<tr>
<td>echo</td>
<td>${title_main}</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${uc}</td>
<td></td>
</tr>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.