Wednesday, February 26, 2014

Random characters generation using javascript in Selenium IDE

By generating the random values using JavaScript in Selenium IDE

  It is possible by injecting with javascript into the Selenium IDE,where scripts are specified below,

Random function for specified values:
command:store
target:javascript
{
var random_chars="abcdefghijklmnopqrstuvwxyz1234567890";
var random_string_generated="";
                                for(var i=0;i<5;i++)
       {
         var ran_no=Math.floor(Math.random()*random_chars.length);
         randomstring+=random_chars.substring(ran_no,ran_no+1);
       }
 }
value:random_string_generated

For displaying the random command:
 command:echo
target:${random_string_generated}

Append the random values to existing values:
command:type
target:id=abcd.....
value:${random_string_generated}

No comments: