On Mon, Sep 26, 2005 at 07:27:42PM +0100, John J Lee wrote: > Seen this? > > http://www.masswerk.at/jsuix/
Cool! I haven't seen that before. What we're looking to do is make something that could run for all textareas (via greasemonkey or something) so that we could always use vi commands. I actually got it working with the help of user-extensions.js. I created an inputKeys command that calls the textarea onkeypress callback for every key. If the callback returns true, it'll also add it to the textbox. This fulfills our testing requirements. I'm not a js pro, so I don't know how cross-browser this is. My user-extensions.js: // try to simulate a key press to a textarea // it will strip off double quotes too Selenium.prototype.doInputKeys = function(locator, keys) { // strip off any quotes if (keys[0] == '"' && keys[keys.length -1] == '"') { keys = keys.substring(1, keys.length -1); } var element = this.page().findElement(locator); for(var i = 0; i < keys.length; i++) { var str = keys[i]; if (sendKeypress(element, str.charCodeAt(0))) { insertAtCursor(element, str); } } } // simulate pressing the escape key Selenium.prototype.doPressEscape = function (locator) { var element = this.page().findElement(locator); sendKeypress(element, 27); } // create an "event" object (heh) and send it to the handler function sendKeypress (element, keyCode, str) { var evt = new Object(); evt.keyCode = keyCode; return element.onkeypress(evt); } // puts text into the form where the cursor currently is function insertAtCursor (myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == 0) { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } Thoughts, comments? Luke -- Luke Closs PureMessage Developer There is always time to juggle in the Sophos Zone. _______________________________________________ Selenium-devel mailing list Selenium-devel@lists.public.thoughtworks.org http://lists.public.thoughtworks.org/mailman/listinfo/selenium-devel