I have been required to verify that the things done onmouseover are
correctly done in our GUI. These are visual things that are defined in
CSS using :hover.
Selenium (I am using the Core based way via RC) has a method mouseOver
that does fire a mouseover event but does not get the :hover rule
active. Others also ran into this problem:
- http://groups.google.com/group/selenium-users/browse_thread/thread/a67bb43f93a24e7b/a9987391f41fc9f9?lnk=gst&q=hover#a9987391f41fc9f9
- http://groups.google.com/group/selenium-users/browse_thread/thread/85edb036895a89a2/d6676152d04cbbf6?lnk=gst&q=hover#d6676152d04cbbf6
I am having here an implementation that would support this, but only
for Firefox Chrome (I am using this on FF3/3.5/3.6). I know that there
are other calls that do not work (the same) on different browsers. I
have not yet opened an issue for that as I would first like to here
your opinions on such browser specific implementations.
Here is what I am doing:
/**
* Overwrites the original mouse out function and additionally
deactivates the pseudo class :hover in Firefox Chrome
*
* @param {String} locator an element locator
*/
Selenium.prototype.doMouseOut = function(locator) {
var element = this.browserbot.findElement(locator);
this.browserbot.triggerMouseEvent(element, 'mouseout', true);
if(browserVersion.isChrome) {
var domUtils = Components.classes["@mozilla.org/inspector/dom-utils;
1"].getService(Components.interfaces.inIDOMUtils);
// check if :hover is currently active
if(0x04 & domUtils.getContentState(element)) {
domUtils.setContentState(element.ownerDocument.documentElement,
0x04);
}
}
};
/**
* Overwrites the original mouse over function and additionally
activates the pseude class :hover in Firefox Chrome
*
* @param {String} locator an element locator
*/
Selenium.prototype.doMouseOver = function(locator) {
var element = this.browserbot.findElement(locator);
this.browserbot.triggerMouseEvent(element, 'mouseover', true);
if(browserVersion.isChrome) {
// set the :hover to active
var domUtils = Components.classes["@mozilla.org/inspector/dom-utils;
1"].getService(Components.interfaces.inIDOMUtils);
domUtils.setContentState(element, 0x04);
}
};
((RenderedWebElement) element).hover();
Regards,
Simon
> --
> You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
> To post to this group, send email to selenium-...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-develo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/selenium-developers?hl=en.
>
>