Instantly share code, notes, and snippets.

Embed
What would you like to do?
generated automatically from #selenium on seleniumhq slack
long finalWindowHeight = (long) ((JavascriptExecutor) getDriver()).executeScript("return pageYOffset");
long browserInnerHeight = (long) ((JavascriptExecutor) getDriver()).executeScript("return window.innerHeight");
long headingHeight = element(By.cssSelector("#objective")).getCoordinates().onPage().getY();
assertThat(finalWindowHeight).isLessThanOrEqualTo(headingHeight).as("Our objective is displayed within viewport");
assertThat(finalWindowHeight + browserInnerHeight).isGreaterThan(headingHeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment