Consider the following scenario,
Functionality to be verified:
Clicking 'Goto Top' link in the bottom of the page should scroll the page such that the WebElement 'Test' gets displayed within the view port.
Please let me know how to verify whether an element is displayed in the current view port or not using WebDriver.
Note: element.isDisplayed will always be true in the above case as the function checks the whole page rather than checking the current view port only.
@Vel Ganesh - I dont know if this can be verified using selenium. But can be definitely done using Sikuli. You can check sikuli.org for details. Sikuli has a Java API and so can be integrated with WebDriver code as well.
Well, as the very last thing coming to my mind, I'd go for something like this:
window.scrollTo
to go to top (see bellow)Where for scrolling using webdriver should work following:
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,0)");
It seems like a desperate workaround, but might be worth an effort if no other solution is suggested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With