Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How to click on File type button across browsers using Selenium Webdriver?

Category: Selenium WebDriver

We can click on a button with across browsers with Selenium webdriver. First of all we need to identify the element with the help of locators like xpath or css, then apply sendKeys() method where the path of the file to be uploaded is passed.

// identify element
      WebElement l=driver.findElement(By.cssSelector("input[type='file']"));
      // file path passed with sendkeys()
      l.sendKeys("C:\Users\ghs6kor\Pictures\Desert.jpg");

Leave a Reply

Your email address will not be published. Required fields are marked *