Thursday, 16 July 2015

Upload a File using Selenium WebDriver


  • Find  web element with tag input and type='file'  using below xpath
//input[@type='file']
  • Make it visible in case of style.visibility='hidden' using javascript
    document.getElementById("myImg").style.visibility = "visible"; 
  •  Send keys on above input element with absolute filepath
   driver.findElement(By.xpath("//input[@type='file']")).sendKeys("/absolute/filepath.jpeg");


Leave comments in case of any queries :)






No comments:

Post a Comment