Workaround for mouseOver with FirefoxDriver

452 views
Skip to first unread message

Juan Carlos

unread,
Jun 3, 2011, 4:23:14 PM6/3/11
to Selenium Users
Hi there,

I'm using Selenium Java 2b03. I have this code:

...
WebDriver driver = new InternetExplorerDriver();
Selenium seleniumDriver = new WebDriverBackedSelenium(driver, "http://
localhost:8088/Sistema/");
...
...
RenderedWebElement menuRegistrarSucursal =
(RenderedWebElement)driver.findElement(By.xpath("//a[normalize-
space()='Registrar']"));
seleniumDriver.mouseOver("//a[normalize-space()='Registrar']");
menuRegistrarSucursal.click();
seleniumDriver.mouseOut("//a[normalize-space()='Registrar']");
...

Works like a charm on Internet Explorer, but it doesn't with a Firefox
driver. I've tried a million things and nothing works. And I must use
the FirefoxDriver because the application I'm testing doesn't behave
well with IE.

As you might guess, the "Registrar" link is hidden until the mouseOver
event triggers.

Any proved workarounds? Thanks for your time...

Luke Inman-Semerau

unread,
Jun 6, 2011, 4:12:49 PM6/6/11
to seleniu...@googlegroups.com
First upgrade to rc2, then start using the Action class:

WebElement menuRegistrarSucursal = driver.findElement(By.xpath("//a[normalize-space()='Registrar']"));
new Actions(driver).moveToElement(menuRegistrarSucursal).build().perform();
menuRegistrarSucursal.click()

The Actions use NativeEvents on the browsers (which is not supported cross platform... I can only get this to work on Windows with FF, doesn't work on Mac nor Linux). So you might want to wrap the action with:
if ((Boolean)((RemoteWebDriver)driver).getCapabilities().getCapability("nativeEvents")) {

and maybe specify the else with something else that sometimes works for you :)


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Juan Carlos

unread,
Jun 8, 2011, 7:25:03 PM6/8/11
to Selenium Users
Hi,

Thanks for the answer! I did just that and it worked. If your curious,
the working code is in this Stackoverflow question:

http://stackoverflow.com/questions/6232390/

Although I didn't know about the native events issue. I'll keep it in
mind. Thanks for the extra info!

On 6 jun, 16:12, Luke Inman-Semerau <luke.seme...@gmail.com> wrote:
> First upgrade to rc2, then start using the Action class:
>
> WebElement
> menuRegistrarSucursal =
> driver.findElement(By.xpath("//a[normalize-space()='Registrar']"));
> new Actions(driver).moveToElement(menuRegistrarSucursal).build().perform();
> menuRegistrarSucursal.click()
>
> The Actions use NativeEvents on the browsers (which is not supported cross
> platform... I can only get this to work on Windows with FF, doesn't work on
> Mac nor Linux). So you might want to wrap the action with:
> if
> ((Boolean)((RemoteWebDriver)driver).getCapabilities().getCapability("native Events"))

Thomas Hallgren

unread,
Jun 17, 2011, 5:49:51 AM6/17/11
to Selenium Users
I would very much like to have this function on Linux but as
predicted, I get the error:

org.openqa.selenium.InvalidElementStateException: Cannot perform
native interaction: native events are disabled on this platform.
System info: os.name: 'Linux', os.arch: 'amd64', os.version:
'2.6.35.13-91.fc14.x86_64', java.version: '1.6.0_20'

What other options do I have to perform a mouseOver using the
WebDriver? Apparently it is possible somehow because it works if I use
a WebDriverBackedSelenium and do a mouseOver.
Reply all
Reply to author
Forward
0 new messages