Search code examples
seleniumfile-uploadautomationblueimp

Automate Blueimp file upload - getting ElementNotVisibleException: Element is not currently visible and so may not be interacted with


i am trying to automate Blueimp file upload. but keep getting ElementNotVisible Exception.

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

I tried to enable using:

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

but still no luck..


Solution

  • One option to solve it would be to make an element visible:

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

    See also: