File Upload in Selenium Webdriver

0 votes

I want to write a script that uploads a file to the server. Using IDE version it uploads the file, but when I export test case as python 2, unit test or WebDriver it is not able to upload. There is no error but it is not uploading the file on the server.

Below is my Python Code:

driver.find_element_by_id("start-upload").click()
driver.find_element_by_css_selector("input[type=\"file\"]").clear()
driver.find_element_by_css_selector("input[type=\"file\"]").send_keys("C:\\\\Desktop\\\\demo.jpeg")

Please provide me a Solution.

May 22, 2018 in Selenium by DareDev
• 6,850 points
760 views

1 answer to this question.

0 votes

The problem I found is excessive backslash(\) is present in the code.

you can try the following code:

driver.find_element_by_id("start-upload").click()
driver.find_element_by_css_selector('input[type="file"]').clear()
driver.find_element_by_css_selector('input[type="file"]').send_keys("C:\\Desktop\\demo.jpeg")
answered May 22, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

Not able to upload a file in Selenium Webdriver using python Scripting

Hey Srinivas, you can checkout this code ...READ MORE

answered Sep 10, 2019 in Selenium by Abha
• 27,930 points
1,759 views
0 votes
1 answer

How do i change the location where my file gets downloaded in Selenium Webdriver and firefox driver?

There are a couple of errors there. ...READ MORE

answered Apr 12, 2018 in Selenium by nsv999
• 5,510 points
3,285 views
0 votes
1 answer

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

The value of name locator has probably ...READ MORE

answered Apr 25, 2018 in Selenium by king_kenny
• 3,710 points
8,687 views
0 votes
1 answer
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,090 points
3,059 views
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,510 points
3,511 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,513 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,585 views
0 votes
1 answer
0 votes
1 answer