java_unable to scroll to view

public static void confirmOkButton(WebDriver driver) {

   WebElement elements = driver.findElement(By.xpath("//button[contains(text(),'OK')]"));

   ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", elements);
  ((JavascriptExecutor) driver).executeScript("arguments[0].click();", elements);

   new WebDriverWait(driver, Long.parseLong(ReadFromProperty.getProperty("PAGE_ELEMENT_TIMEOUT"))).until(ExpectedConditions.invisibilityOfElementLocated(By.className("bx--btn--primary")));

}

原文地址:https://www.cnblogs.com/lutong1989/p/14781268.html