asked 2 years ago
Sometimes a WebElement might not be visible in the current eye view of the webpage. Selenium WebDriver can only interact with elements that are in the visible portion of the page. To interact with such elements, it's necessary to scroll up, down, or move horizontally or vertically. Selenium WebDriver provides a few methods to perform scrolling on the webpage.
Navigate to https://www.qafeast.com/demo ,click the Scrolling tab.
The submit button is at the bottom of the page, selenium webdriver mimics a user to click the control. The submit button is not visible to the user, if selenium scripts are written to click the button then it will throw an error "Element not visible".In order to click the submit button, we can make the scroll at the end of the page, and the button will be visible to click.
To scroll to the webpage JavascriptExecutor class is used.
Scroll to the element:
We can scroll to the particular element, the element could be at the bottom or horizontal using the scroll into view method the focus moved to the element.
Scroll to the bottom of the page
Scroll down to some extent
Scroll to top of the page
Scroll up to some extent