Selenium IDE - How to use "runScript" command in different ways with examples

Many blog readers were asking me for "runScript" command examples. Finally i got some time to prepare few examples for "runScript" command. There is not one specific use of "runScript" command but we can use it in different ways for different conditions. BTW, you can Look at different examples of using javascript with selenium IDE.

"runScript" Command
"runScript" command runs the JavaScript snippet specified in target column of selenium IDE software window. Let we take one simple example for more clarification.

Example 1 : Simple "runScript" Command To Generate Alert


New Test
CommandTargetValue
runScriptjavascript{alert(" 'DO YOU LIKE ALL THESE EXAMPLES? :) IF YES THEN SUBSCRIBE VIA EMAIL TO GET MORE SUCH EXAMPLES ON YOUR EMAIL ID' ")}

CLICK HERE to view all examples of "runScript" command.

In above example, "runScript" command will run JavaScript snippet. You can provide your own JavaScript snippet in target of the command. Here, it will show you an alert message when you run it in selenium IDE.

My request to all my blog readers - Please share javascript snippet if you have used it for any purpose in selenium IDE by posting comment bellow.

1 comment:

  1. Hi Aravind,
    thank you for very helpful posts.
    How to call command line external tool from selenium ide.
    For example i want to run dir command and get stdout in text.
    I tried to use runScript using

    javascript{ var exec = document.require('child_process').exec; exec('dir', function callback(error, stdout, stderr){alert(stdout); });}

    but it raises error: TypeError: document.require is not a function.

    Thank you.

    ReplyDelete