If some buttons are visible or not, my program is doing different actions. In order to see those buttons i need to scroll to them.
I want to see this:

instead i see like this:

I use this code:
JavascriptExecutor je=(JavascriptExecutor) driver;
WebElement elem=driver.findElement(By.xpath("//a[contains(.,'"+username+"')]/ancestor::div[contains(@class, 'js-answer-element')]"));
je.executeScript("arguments[0].scrollIntoView(true)", elem);
How can scroll until all the square is into view?
The container is scrolled at the top of the view, which is exactly what you instructed by calling arguments[0].scrollIntoView(true).
If you want it at the bottom instead:
je.executeScript("arguments[0].scrollIntoView(false)", elem);
Or with an offset from the top:
je.executeScript("arguments[0].scrollIntoView(true); window.scrollBy(0, -60);", elem);
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