I am trying to scroll down and click the ‘Purchase’ button on the following page once the place order button is clicked https://www.demoblaze.com/cart.html but I keep running into the following error:
org.openqa.selenium.ElementNotInteractableException: Element <button class="btn btn-primary" type="button"> could not be scrolled into view
I have tried using the JavascriptExecutor but I haven’t been able to get this working. Any advise on what I am doing wrong?
This is the code I have recently used
JavascriptExecutor js = (JavascriptExecutor) getDriver();
WebElement element = getDriver().findElement(By.cssSelector("button.btn-primary"));
WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
js.executeScript("arguments[0].scrollIntoView(true);", element);
element.click();