Advertisement
Guest User

Selenium IDE user extension example 3

a guest
Nov 28th, 2012
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Selenium.prototype.doTypeRandomEmail = function(locator) {
  2.     /**
  3.     * Sets the value of an input field to a random email id,
  4.     * as though you typed it in.
  5.     *
  6.     * @param locator an <a href="#locators">element locator</a>
  7.     */
  8.  
  9.     // All locator-strategies are automatically handled by "findElement"
  10.     var element = this.page().findElement(locator);
  11.  
  12.     /* The following block generates a random email string */
  13.     var allowedChars = "abcdefghiklmnopqrstuvwxyz";
  14.     var stringLength = 8;
  15.     var randomstring = '';
  16.  
  17.     for (var i=0; i<stringLength; i++) {
  18.         var rnum = Math.floor(Math.random() * allowedChars.length);
  19.         randomstring += allowedChars.substring(rnum,rnum+1);
  20.     }
  21.  
  22.     // Append a domain name
  23.     randomstring += "@somedomain.com"
  24.  
  25.     // Replace the element text with the new text
  26.     this.browserbot.replaceText(element, randomstring);
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement