Uploading File using Selenium WebDriver

0 votes
How to upload a file using Selenium WebDriver, with the help of Java as the programming Language?

After clicking on a button present on the web application, the application gets open in the new window.

what can I do, to select upload file?
May 2, 2018 in Selenium by DareDev
• 6,870 points
598 views

1 answer to this question.

0 votes

Make sure that the input element is visible on the screen.

You should not click on the browse button, as it will trigger the OS dialogue box and effectively stop the test execution.

You can use the below code:

driver.findElement(By.id("UploadFile")).sendKeys("<absolutePathOfTheFile>");

UploadFile is the Id of the element (i.e. button) and in sendKeys specify the path of the file that is to be uploaded.

answered May 2, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,340 points
1,230 views
0 votes
1 answer

Downloading *.jar file from http:// seleniumhq.org using Selenium WebDriver

For Selenium Standalone Server: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); If downloading ...READ MORE

answered Apr 17, 2018 in Selenium by Shubham
• 13,450 points
2,174 views
0 votes
1 answer

Reading the pdf file using selenium webdriver

Use should use PDFBox and FontBox. ...READ MORE

answered Apr 25, 2018 in Selenium by Vardy
• 2,360 points
4,894 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,774 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,758 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,735 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,098 views
0 votes
1 answer
0 votes
1 answer

Uploading files using selenium WebDriver

Try using input() function: WebElement fileInput = driver.fin ...READ MORE

answered Jul 5, 2018 in Selenium by Meci Matt
• 9,460 points
82 views