[prev in list] [next in list] [prev in thread] [next in thread] 

List:       selenium-commits
Subject:    [Selenium-commits] [JIRA] Commented: (SEL-143) Key and Mouse events
From:       "Alexander Dvoretskiy (JIRA)" <jira () public ! thoughtworks ! org>
Date:       2005-08-19 11:33:38
Message-ID: 8624270.1124451218626.JavaMail.jira () atlassian ! public ! thoughtworks ! org
[Download RAW message or body]

    [ http://jira.public.thoughtworks.org/browse/SEL-143?page=comments#action_12016 ] \


Alexander Dvoretskiy commented on SEL-143:
------------------------------------------

Excellent! Thank you.  I needed that too, added methods in local copy but didn't find \
time to prepare changes to be commited.

> Key and Mouse events
> --------------------
> 
> Key: SEL-143
> URL: http://jira.public.thoughtworks.org/browse/SEL-143
> Project: Selenium
> Type: New Feature
> Components: BrowserBot
> Reporter: fjh fekkes
> Priority: Minor

> 
> 
> Hello,
> in a try out of selenium I needed the keyevents and mouseevents to be accessible \
> also. Therefor I extended the browserbot by the triggerKeyEvent (triggerMouseEvent \
> was already there) and the subsequent functions to make the commands available \
> (Keypress, Keydown, Mouseover and Mousedown).  I only defined the commands and \
> browsers (IE and MOZ) I need at the moment, the other events are a straigthforward \
> exercise  Regards,
> Fekke
> << htmlutils.js >>
> /* FJH Fire a key event in a browser-compatible manner */
> function triggerKeyEvent(element, eventType, keycode, canBubble) {
> canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
> if (element.fireEvent) {
> 	keyEvent = parent.frames['myiframe'].document.createEventObject();
> 	keyEvent.keyCode=keycode;
> 	element.fireEvent('on' + eventType, keyEvent);
> }
> else {
> var evt = document.createEvent('KeyEvents');
> evt.initKeyEvent(eventType, true, true, window, false, false, false, false, \
> keycode, keycode); element.dispatchEvent(evt);
> }
> }
> /* END FJH */
> << selenium-api.js >>
> /*
> * FJH Key, Mouse event on the located element
> */
> Selenium.prototype.doKeypress = function(locator, keycode) {
> var element = this.page().findElement(locator);
> this.page().keypressElement(element, keycode);
> };
> Selenium.prototype.doKeydown = function(locator, keycode) {
> var element = this.page().findElement(locator);
> this.page().keydownElement(element, keycode);
> };
> Selenium.prototype.doMouseover = function(locator) {
> var element = this.page().findElement(locator);
> this.page().mouseoverElement(element);
> };
> Selenium.prototype.doMousedown = function(locator) {
> var element = this.page().findElement(locator);
> this.page().mousedownElement(element);
> };
> /* END FJH */
> << selenium-browserbot.js >>
> /* FJH Key, Mouse events */
> MozillaPageBot.prototype.keypressElement = function(element, keycode) {
> triggerEvent(element, 'focus', false);
> // Trigger the key event.
> triggerKeyEvent(element, 'keypress', keycode, true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> MozillaPageBot.prototype.keydownElement = function(element, keycode) {
> triggerEvent(element, 'focus', false);
> // Trigger the key event.
> triggerKeyEvent(element, 'keydown', keycode, true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> IEPageBot.prototype.keypressElement = function(element, keycode) {
> triggerEvent(element, 'focus', false);
> // Trigger the key event.
> triggerKeyEvent(element, 'keypress', keycode, true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> IEPageBot.prototype.keydownElement = function(element, keycode) {
> triggerEvent(element, 'focus', false);
> // Trigger the key event.
> triggerKeyEvent(element, 'keydown', keycode, true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> MozillaPageBot.prototype.mouseoverElement = function(element) {
> triggerEvent(element, 'focus', false);
> // Trigger the mouse event.
> triggerMouseEvent(element, 'mouseover', true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> MozillaPageBot.prototype.mousedownElement = function(element) {
> triggerEvent(element, 'focus', false);
> // Trigger the mouse event.
> triggerMouseEvent(element, 'mousedown', true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> IEPageBot.prototype.mouseoverElement = function(element) {
> triggerEvent(element, 'focus', false);
> // Trigger the mouse event.
> triggerMouseEvent(element, 'mouseover', true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> IEPageBot.prototype.mousedownElement = function(element) {
> triggerEvent(element, 'focus', false);
> // Trigger the mouse event.
> triggerMouseEvent(element, 'mousedown', true);
> if (this.windowClosed()) {
> return;
> }
> triggerEvent(element, 'blur', false);
> };
> /* END FJH */

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.public.thoughtworks.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

_______________________________________________
Selenium-commits mailing list
Selenium-commits@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic