org.openqa.selenium.ElementNotInteractableException: Element <a class=“bg-inverse ”> could not be scrolled into view when trying to click a button

﹥>﹥吖頭↗ 提交于 2019-11-26 19:13:21

This error message...

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: Element <a class="bg-inverse text-white dropdown-item" href="/admin/worker-summary"> could not be scrolled into view

...implies that the GeckoDriver / FirefoxDriver was unable to interact with the desired element.

Solution

Once you locate the element btnWorkerSummary moving ahead as you are invoking click() instead of ExpectedConditions as visibilityOf you need to use elementToBeClickable() as follows:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='/admin/worker-summary']"))).click();

However, another issue is the incompatibility between the version of the binaries you are using as follows:

  • Your Selenium Client version is 3.12.0.
  • Your JDK version is 1.8.0_51 which is ancient.

Solution

  • Upgrade JDK to recent levels JDK 8u201.
  • Execute your @Test.

Try to use javascriptexecutor as shown sample code below,

JavascriptExecutor je = (JavascriptExecutor) driver;
je.executeScript("arguments[0].scrollIntoView(true);",driver.findElement(By.xpath("//a[@href='/admin/worker-summary']")));

You can simply try following js to scroll the page.Enter Pixel asper your requirement to scroll page. Here I use 3000 Px to scroll page to mid

   JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("window.scrollBy(0,3000)");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!