0 Replies Last post: Jul 2, 2008 2:18 PM by Dave Stewart  
Dave Stewart Expert 213 posts since
Mar 25, 2008
Currently Being Moderated

Jul 2, 2008 2:24 PM

New user-extensions.js procedure to select all selections in a multi-select element

Just add this to your user-extensions.js file if you want to be able to select all the items in a multi select element.  It's just a quick modification of the code that allows us to UNselect all options.

 


Selenium.prototype.doSelectAllSelections = function(locator) {
    /**
    * Selects all of the selected options in a multi-select element.
    *
    * @param locator an <a href="#locators">element locator</a> identifying a multi-select box
    */
    var element = this.browserbot.findElement(locator);
    if (!("options" in element)) {
        throw new SeleniumError("Specified element is not a Select (has no options)");
    }
    for (var i = 0; i&lt;element.options.length; i++) {
        this.browserbot.addSelection(element, element.options[ i]);
    }
}

 

Edit: You may have to remove the leading space before the "i" in the array reference, the forum software is mucking with what I post if I don't put the extra space in there.

More Like This

  • Retrieving data ...