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,890 points
1,132 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,320 points
3,214 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,490 points
5,932 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
7,381 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,500 points
12,616 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,572 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,910 points
6,629 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 3, 2020 in Selenium by Sri
• 3,190 points
7,517 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
353 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP