1

I'm using FluentLenium.

I'm trying to simulate a on_mouse_over in my java tests. I have to check some boxes in a drop down menu, it's an element not visible...

I have to move the mouse over to make visible this element and be able to use the method click() from FluentLenium.

How can i "simulate" a on_mouse_over in java?

Thanks

4

2 回答 2

3

Thanks everyone for your help !

I found the solution :

Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.cssSelector("ul.critereFiltrage")).findElement(By.cssSelector("a"))).moveToElement(driver.findElement(By.cssSelector("div.overview")).findElement(By.cssSelector("a"))).click().build().perform();

To explain :

  • The first moveToElement() => To go on the A-tag to open the DropDown menu
  • The second moveToElement() => To go on the first item in the DropDown Menu
  • click() => click on the selected item
  • build() => To generate a composite action
  • perform() => To launch the built action.

Thanks a lot,

于 2013-06-21T12:15:49.210 回答
1

You would need to use the Actions() class.

Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id("opens_menu"))).moveToElement(driver.findElement(By.id("hidden_element"))).click().build().perform();

Docs are here: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html

于 2013-06-20T14:44:59.647 回答