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,810 points
410 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,420 points

Related Questions In Selenium

0 votes
1 answer
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,090 points
1,496 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,650 points
2,994 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 in Selenium by Anvi
• 12,840 points
139 views
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
554 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
888 views
0 votes
1 answer
0 votes
1 answer