Why hover to element and click submenu does not work when browser is opened full screen?

喜你入骨 提交于 2019-12-24 00:27:50

问题


I am working on a page where a left hand main menu has submenus. I try to hover to the main menu item, and it will show the submenu, and then I will click the submenu.

I am using below code:

@FindBy(id = "xxx")
private WebElementFacade mainmenu;

@FindBy(id = "yyy")
private WebElementFacade submenu;

Actions builder = new Actions(getDriver());
builder.moveToElement(mainmenu).perform();
submenu.waitUntilClickable().click();

I've tried other ways like:

action.moveToElement(mainmenu).moveToElement(submenu).click().build().perform();

It seems the problem is: when the test is performed when browser is in full screen, i.e.

driver.manage().window().maximize();

the main menu sometimes flash very quickly as if it's clicked really fast and recede, other times it appears not clicked or hovered to at all.

Because this hover and click active happens immediately after user navigate to the page, I add wait for element on the main menu, but it does not seem to work.

Any ideas how to solve the problem? I do not understand why it happens only when browser is in full screen mode. The only reason I can think of is the main menu element need more time to load.

EDIT:

Btw, the issue is very severe in Chrome. Firefox is better, but not 100% working either. It seems that even a simple hover:

mainmenu.waitUntilPresent();
Actions builder = new Actions(getDriver());
builder.moveToElement(mainmenu)perform();

does not always make the main menu display its submenu. I do not understand why it does not work.

来源:https://stackoverflow.com/questions/35855636/why-hover-to-element-and-click-submenu-does-not-work-when-browser-is-opened-full

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!