We've had a need to check that we're not editing disabled fields or writing too much text into a text field so I've patched doType and doSelect as below. Haven't really explored browser compatibility issues (we're developing for IE) or completeness with regards to other commands. But hopefully this should get the ball rolling.

Selenium.prototype.doType = function(locator, newText) {
   var element = this.page().findElement(locator);
if (typeof(element.disabled) != 'undefined' && element.disabled == true) {
       throw new SeleniumError('Specified element is disabled');
   }
if (typeof(element.maxLength) != 'undefined' && element.maxLength < newText.length) { throw new SeleniumError('Specified element is too small for value \'' + newText + '\' (maxLength=' + element.maxLength + ')');
   }
   this.page().replaceText(element, newText);
};

Selenium.prototype.doSelect = function(locator, optionLocator) {
   var element = this.page().findElement(locator);
   if (!("options" in element)) {
throw new SeleniumError("Specified element is not a Select (has no options)");
   }
if (typeof(element.disabled) != 'undefined' && element.disabled == true) {
       throw new SeleniumError('Specified element is disabled');
   }
var locator = this.optionLocatorFactory.fromLocatorString(optionLocator);
   var option = locator.findOption(element);
   this.page().selectOption(element, option);
};

--
*Matt Bates* |Senior Developer |*RHE & Associates Limited* |
_______________________________________________
Selenium-devel mailing list
Selenium-devel@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-devel

Reply via email to