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,810 points
173 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,420 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,220 points
476 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,290 points
373 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,250 points
2,297 views
0 votes
1 answer
0 votes
1 answer

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,090 points
580 views
0 votes
1 answer
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,130 points
898 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
570 views
0 votes
1 answer
0 votes
1 answer

Uploading files using selenium WebDriver

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

answered Jul 5, 2018 in Selenium by Meci Matt
• 9,420 points
27 views