In my previous post, I described how to generate alert message using "runScript" command in selenium IDE. In this example, Let we see how can we show variable value inside alert using "runScript" command. Copy paste bellow given example in your selenium IDE and run it.
Example 2 : "runScript" Command With Variable In Script
New Test | ||
Command | Target | Value |
open | http://only-testing-blog.blogspot.com/2013/09/testing.html | |
addSelection | name=FromLB | label=Russia |
click | css=input[type="button"] | |
storeTable | css=table.0.2 | lblname |
runScript | javascript{alert("Selenium has moved label '" + storedVars['lblname'] + "' at right side.")} | |
storeAlert | alert | |
echo | ${alert} |
CLICK HERE to look at more real world examples of "runScript" command.
In above example,
"storeTable" command will store label name in to variable 'lblname' which is moved between list boxes.
"runScript" command will show you alert message including variable value.
You can view how to generate alert in selenium webdriver with example on THIS LINK.
Use selenium IDE and webdriver examples in your software application test cases to get them better.
How to use alert for alert box with value in a store
ReplyDeleteif plain text then we use javascript{alert("Hello")} but I want to use variable instead of text hello