0

I want to upload the picture so that I can access it in my project, I have used the sendKeys("path of the picture") but by using it no action is performed, please guide me, how to use the window pop up to upload the picture or give some idea, how can I upload the picture:

WebElement Account_logo = adriver.findElement(By.xpath("//*[@id='step1']/div[1]/div/div/div/form/div[12]/div[1]/div/div/span/div[2]/div[2]"));  
Account_logo.click();
Account_logo.sendKeys("C:/Users/romit/Desktop/LOGO.jpg");
5
  • on which browser you are testing this scenario ? Have you tried autoIT or robot class ? Commented Apr 10, 2018 at 10:43
  • AFAIK, a <div> tag won't accept a filename. Perhaps you have to use the file picker. Commented Apr 10, 2018 at 10:46
  • Share your HTML. Commented Apr 10, 2018 at 10:51
  • comment the 2nd line and run it. Commented Apr 10, 2018 at 11:22
  • I am testing it on the chrome browser, I have tried the robot and still not upload the picture @cruisepandey Commented Apr 11, 2018 at 9:53

1 Answer 1

0

When setting the file path in your Java IDE, use the proper escape character for the back-slash.

Account_logo.sendKeys("C:\\Users\\romit\\Desktop\\LOGO.jpg");

Hope it helps !

If you want to upload a file, without having 'input' element, please refer SO Post

Sign up to request clarification or add additional context in comments.

1 Comment

Could you please tell more about your uploading mechanism. do you have file input put field and submit button ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.