自动Blueimp获取ElementNotVisibleException:元素当前不可见,因此可能无法与之交互



我正在尝试自动上传Blueimp文件。但不断出现CCD_ 1异常。

WebElement fileUpload = driver.findElement(By.xpath("//input[@type='file']"));
String imagePath = "image.png";
fileUpload.sendKeys(imagePath);

我尝试启用使用:

((JavascriptExecutor)driver).executeScript("arguments[0].checked = true;", fileUpload);`

但是仍然没有运气。。

解决问题的一个选项是使元素可见

WebElement fileUpload = driver.findElement(By.xpath("//input[@type='file']"));
((JavascriptExecutor)driver).executeScript("arguments[0].style.display = 'block'; arguments[0].style.visibility = 'visible';", fileUpload);
String imagePath = "image.png";
fileUpload.sendKeys(imagePath);

另请参阅:

  • 如何创建javascript执行器以使元素在selenium webdriver中可见
  • Selenium Webdriver-点击隐藏元素

最新更新