I am trying to click on button which is not viewable on to the screen so that first I have to scroll the window and then perform click operation, but before scrolling entirely happens using JavascriptExecutor
, Selenium tries to click on button which leads to ElementClickInterceptedException
.
WebElement submitButton = driver.findElement(By.cssSelector(".totalRow button"));
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", submitButton);
w.until(ExpectedConditions.elementToBeClickable(submitButton));
submitButton.click();
If I use Thread.sleep(5000)
after scrolling this issue does not happen, but I do not want to use that. I tried using JavascriptExecutor
and Action
class that did not work either.