首页 > 解决方案 > org.openqa.selenium.ElementNotVisibleException:元素不可交互

问题描述

无法单击应用程序中的任何按钮。

错误堆栈跟踪:

org.openqa.selenium.ElementNotVisibleException: element not interactable
  (Session info: chrome=73.0.3683.103)
  (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.10.0', revision: '176b4a9', time: '2018-03-02T19:03:16.397Z'
System info: host: 'SHIPAWAR-54Q9D', ip: '10.65.75.122', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.chrome.ChromeDriver

我尝试了 java 脚本执行器,动作类,但它们都不起作用

 public void clickHERE(String deal) throws Throwable{   
    javaScriptClick(driver, HERE);
    driver.findElement(By.xpath(enterDeal)).sendKeys(deal);
    Thread.sleep(5000);
    int ok_size=driver.findElements(By.cssSelector("[name=SearchDeal]")).size();
    System.out.println("the search button size:" +ok_size);

    driver.findElement(By.xpath(enterDeal)).sendKeys(Keys.ENTER);
    Thread.sleep(5000);
    scrollToElement(driver, nextTabDealInfo);
    driver.findElement(By.xpath(nextTabDealInfo)).click(); // this button in not working

}

应该可以点击按钮。

nextTabDealInfo是xpath:

//*[@type='button' and contains(@value,'Next Tab')] 

按钮的 HTML:

<input type="button" name="fromOptyInfoTab" value="Next Tab >" onclick="return switchTabs('nonStandardInfo.do');" class="buttonNextTab">

标签: javaseleniumgoogle-chromewebdriverselenium-chromedriver

解决方案


此错误消息...

org.openqa.selenium.ElementNotVisibleException: element not interactable
.
System info: host: 'SHIPAWAR-54Q9D', ip: '10.65.75.122', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'

...表示ChromeDriver无法与Chrome 浏览器会话进行通信。

您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:

  • 您的Selenium 客户端版本是2018-03-02T19 : 03:16.397Z的 ​​3.10.0 ,差不多一年了。
  • 您的JDK 版本1.8.0_60,它非常古老。

因此JDK v8u60Selenium Client v3.10.0之间存在明显的不匹配

解决方案


推荐阅读