int initialHeight = menu.getSize().getHeight();
int y = menu.getLocation().getY();
closeContextMenu();
Dimension size = getDriver().manage().window().getSize();
int windowHeight = initialHeight - 10;
if (isElementPresent(By.className("v-ch"))) {
// Chrome does something wrong with window height
windowHeight = y + initialHeight;
}
getDriver().manage().window()
.setSize(new Dimension(size.getWidth(), windowHeight));
menu = openContextMenu();
int height = menu.getSize().getHeight();
Assert.assertTrue(
"Context menu height has not been descreased after "
+ "window height update to value lower than context menu initial height",
initialHeight > height);
closeContextMenu();
getDriver().manage().window()
.setSize(new Dimension(size.getWidth(), size.getHeight()));
menu = openContextMenu();
height = menu.getSize().getHeight();
Assert.assertEquals("Context menu height has not been reset after "
+ "window height reset", initialHeight, height);
}