【问题标题】:Automate Blueimp file upload - getting ElementNotVisibleException: Element is not currently visible and so may not be interacted with自动上传 Blueimp 文件 - 获取 ElementNotVisibleException:元素当前不可见,因此可能无法与之交互
【发布时间】:2015-05-21 13:16:54
【问题描述】:

我正在尝试自动上传 Blueimp 文件。但不断收到ElementNotVisible 异常。

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

我尝试启用:

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

但仍然没有运气..

【问题讨论】:

    标签: selenium file-upload automation blueimp


    【解决方案1】:

    解决此问题的一种方法是使元素可见

    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);
    

    另见:

    【讨论】:

      猜你喜欢
      • 2016-11-13
      • 1970-01-01
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-27
      相关资源
      最近更新 更多