Selenium IDE - "runScript" Command example to generate alert including variable value

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
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2013/09/testing.html
addSelectionname=FromLBlabel=Russia
clickcss=input[type="button"]
storeTablecss=table.0.2lblname
runScriptjavascript{alert("Selenium has moved label '" + storedVars['lblname'] + "' at right side.")}
storeAlertalert
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.

1 comment:

  1. How to use alert for alert box with value in a store

    if plain text then we use javascript{alert("Hello")} but I want to use variable instead of text hello

    ReplyDelete