You can add user exentions.js to get the random values .
Copy the below code and save it as .js extension (randomgenerator.js) and add it to the Selenium core extensions (SeleniumIDE-->Options--->general tab)
Selenium.prototype.doRandomString = function( options, varName ) {
var length = 8;
var type = 'alphanumeric';
var o = options.split( '|' );
for ( var i = 0 ; i < 2 ; i ++ ) {
if ( o[i] && o[i].match( /^\d+$/ ) )
length = o[i];
if ( o[i] && o[i].match( /^(?:alpha)?(?:numeric)?$/ ) )
type = o[i];
}
switch( type ) {
case 'alpha' : storedVars[ varName ] = randomAlpha( length ); break;
case 'numeric' : storedVars[ varName ] = randomNumeric( length ); break;
case 'alphanumeric' : storedVars[ varName ] = randomAlphaNumeric( length ); break;
default : storedVars[ varName ] randomString= randomAlphaNumeric( length );
};
};
function randomNumeric ( length ) {
return generateRandomString( length, '0123456789'.split( '' ) );
}
function randomAlpha ( length ) {
var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( '' );
return generateRandomString( length, alpha );
}
function randomAlphaNumeric ( length ) {
var alphanumeric = '01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( '' );
return generateRandomString( length, alphanumeric );
}
function generateRandomString( length, chars ) {
var string = '';
for ( var i = 0 ; i < length ; i++ )
string += chars[ Math.floor( Math.random() * chars.length ) ];
return string;
}
Way to use
Command Target Value
----------- --------- ----------
randomString 6 x
type username ${x}
Above code generates 6 charactes string and it assign to the variable x
Code in HTML format looks like below:
<tr>
<td>randomString</td>
<td>6</td>
<td>x</td>
</tr>
<tr>
<td>type</td>
<td>username</td>
<td>${x}</td>
</tr>