I am unable to click a button that's outside of the viewport on a page. I have tried a couple of things, none of which work:
button.click()
Actions.click(button).peform()
Actions.moveToElement(button).click().build().peform()
All of the above throw a MoveTargetOutOfBoundsException
.
I have tried scrolling the button into view, but these all don't do anything:
((JavascriptExecutor)driver).executeScript("window.scrollTo(0, document.body.scrollHeight)")
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", button)
driver.findElement(By.tagName("body")).sendKeys(Keys.PAGE_DOWN)
I have checked the page for iframe
s; the page doesn't contain any. It should be noted that when I add a delay and scroll the page down manually, the button is immediately clicked when it's in view, so that leads me to believe it's not an issue with the button, but rather with the page not wanting to be scrolled down.
I cannot share the page, but I can provide snippets of the page's HTML if needed.
- Java 16
- Selenium 4
- Chromedriver 99