|
Implemented as part of drag+drop support. Thanks for the patch, Charles – that gave me an excellent headstart on this task. I did end up making a number of changes, some related to bugs but probably more related to various re-factorings to share logic between this and other related tasks. I think it could be worthwhile to review and compare the fixes you have made in your own code with what selenium has now. Would you mind attaching your latest to this JIRA issue so I could compare what you have with selenium's code? Sure, no problem. Except I can't figure out how to attach another file...so its inline below. Any thoughts on when the next release will be? I'd be happy to download the latest and greatest to test these changes when they are ready. Thanks, Charlie ----------------- /* Taken from prototype library */ function getClientXY(element, coordString) { // Get position of element // Return 2 item array with clientX and clientY function triggerMouseEvent(element, eventType, canBubble, clientX, clientY) { clientX = clientX || 0 if (window.screenX) { // Firefox screenX = window.screenX + clientX screenY = window.screenY + clientY }else if (window.screenLeft) { // IE screenX = window.screenLeft + clientX screenY = window.screenTop + clientY } if (element.fireEvent) {
var mouseEvent = document.createEventObject()
mouseEvent.clientX = clientX
mouseEvent.clientY = clientY
mouseEvent.screenX = screenX
mouseEvent.screenY = screenY
element.fireEvent('on' + eventType);
} else { // Safari // TODO we should be initialising other mouse-event related attributes here evt.initEvent(eventType, canBubble, true); } element.dispatchEvent(evt); Selenium.prototype.doClick = function(locator, coordString) {
Selenium.prototype.doMouseMove = function(locator, coordString) {
var element = this.page().findElement(locator); triggerMouseEvent(element, 'mousemove', true, clientXY[0], clientXY[1]); Selenium.prototype.doMouseDown = function(locator, coordString) {
triggerMouseEvent(element, 'mousedown', true, clientXY[0], clientXY[1]); Selenium.prototype.doMouseUp = function(locator, coordString) {
triggerMouseEvent(element, 'mouseup', true, clientXY[0], clientXY[1]); // TODO Opera uses this too - split out an Opera version so we don't need the isGecko check here triggerEvent(element, 'focus', false); // Add an event listener that detects if the default action has been prevented. // Trigger the click event. // Perform the link action if preventDefault was set. if (this.windowClosed()) {
return;
} triggerEvent(element, 'blur', false); SafariPageBot.prototype.clickElement = function(element, clientX, clientY) { triggerEvent(element, 'focus', false); var wasChecked = element.checked; // For form element it is simple. // Unfortunately, triggering the event doesn't seem to activate onclick handlers. if (success) { if (this.windowClosed()) { return; } triggerEvent(element, 'blur', false); IEPageBot.prototype.clickElement = function(element, clientX, clientY) { triggerEvent(element, 'focus', false); var wasChecked = element.checked; // Set a flag that records if the page will unload - this isn't always accurate, because element.click(); // If the page is going to unload - still attempt to fire any subsequent events. if (this.windowClosed()) { return; } // Onchange event is not triggered automatically in IE. triggerEvent(element, 'blur', false); The timing of the next release is currently being debated. My guess is that it will be within the next week or so. |
|||||||||||||||||||||||||||||||||||||
Hi - I've added this support to my version of selenium. I've attached my changes - note they are not in the form of a patch since I just overrode methods in my user-extensions.js file. But I can turn them into a patch if needed.
What the code does:
mouseMove | some_id | 17, 12
Hope this helps - feel free to ask questions. And if you'd prefer a patch let me know.