How to handle the popup of file upload in Windows OS with WebDriver

0 votes

I saw another thread with solutions for uploading files using WebDriver. But none of them are working on the below sites.

http://www.uploadify.com/demos/
http://www.zamzar.com/

I'm using the below code and i'm still getting errors. Suggestions and edits are welcome :)

WebElement fileInput = driver.findElement(By.name("uploadfile"));
fileInput.sendKeys("C:/path/to/file.jpg");
Apr 25, 2018 in Selenium by kappa3010
• 2,090 points
17,906 views

1 answer to this question.

0 votes

The value of name locator has probably changed to "file_1" now. Or else you can use id locator with this value and try once "inputFile".

WebElement fileInput = driver.findElement(By.name("file_1"));
fileInput.sendKeys("C:/path/to/file.jpg");

If this still does not work, then try this:

driver.findElement(By.id("inputFile")).click();
driver.switchTo()
       .activeElement()
       .sendKeys("C:/path/to/file.jpg");
answered Apr 25, 2018 by king_kenny
• 3,710 points
When click on that element then the file select popup was open

After upload, how to close the file selection popup

Hey Siva, to upload a file, you don't need to open File Select window. Instead, you can use this line of code to directly mention the file you wish to upload using sendKeys() method:

uploadElement.sendKeys("File_path");

Related Questions In Selenium

0 votes
1 answer
+1 vote
1 answer

How to handle notifications in Python with Selenium (Chrome WebDriver)

Below will help you: You can disable the ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
13,743 views
0 votes
1 answer

How to handle multiple windows in Selenium Webdriver?

Hey Ritika, you can handle multiple windows ...READ MORE

answered May 24, 2019 in Selenium by Anvi
• 14,150 points
531 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,728 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,616 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,690 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,555 views
+2 votes
3 answers

How can we handle authentication popup in Selenium WebDriver using Java

1) By passing user credentials in URL. String ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
28,419 views
0 votes
1 answer

How to open a browser windows silently in the background?

It is a little bit of a ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,710 points
5,250 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