java. serenity. Hover over element in Chrome

3.5k views Asked by At

I'm doing automated tests of a web application in Java/Serenity.

There is a menue with submenues in the app. It's a javascript menu which opens submenues onmouseover. I need to open submenues of any level via Serenity. I'm doing it using the following code:

public void hoverElement(WebElementFacade element) {
    Actions builder = new Actions(getDriver());
    Actions hoverOverLocationSelector = builder.moveToElement(element);
    hoverOverLocationSelector.perform();
}

It works very well in Firefox, but not in Chrome.

In Chrome, I have to call the hoverElement() function two or three times in a row to make it work. And this is not good.

Does anyone have ideas how to make it work without calling the function two or three times?

Thanks in advance.

1

There are 1 answers

0
Blitzoff On

Just came across this question, but might help others. This worked for me for choosing an item in a menu:

withAction().moveToElement(element(by_menu)).moveToElement(element(by_login)).click().build().perform();

It navigates to the menu, then to the item and then clicks. Build-perform executes it in sequence