Scroll with JavaScript
Use page.evaluate to scroll the page, or locator.scrollIntoViewIfNeeded() to scroll to a specific element.
Task:
- Navigate to
https://testkru.com/Elements/Tables - Scroll down by 300 pixels by calling
window.scrollBy()insidepage.evaluate() - Read
window.scrollYand print whether it is greater than 0 (the exact number depends on the window size, because the browser stops at the bottom of the page) - Use
scrollIntoViewIfNeeded()on the employee table - Print that it completed
Expected output:
Scrolled down: true Table scrolled into view: true
TestKru