java - 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">
解决方案
此错误消息...
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 v8u60和Selenium Client v3.10.0之间存在明显的不匹配
解决方案
- 将JDK升级到最新级别JDK 8u202。
- 将Selenium升级到当前级别版本 3.141.59。
推荐阅读
- javascript - React-Native 嵌套导航导致出现 2 个菜单
- c++ - 将值 caputring lambda 传递给需要函数指针的函数
- output - logstash 限制输出文件的大小
- kubernetes - Pod 在 Kubernetes 中启动但不工作
- c# - 使用 c# 发送包含嵌入图像(Base64)的电子邮件
- javascript - Node/NestJs:如何从方法中注入类?
- python - Keras 中的 2CNN:形状不匹配
- mongodb - 如何获取原始 M 中的值
- python - 如何使用 python 正则表达式捕获乘法的重复操作数
- c++ - 快速填充 boost::unordered_set