0
votes

I'm stuck with file upload. I tried using:

Choose File my_upload_field ${CURDIR}/trades.csv keyword from selenium2library
and here is my code:

Choose File ${ClickToUploadFileSection} /UsersDownloads/filename.pdf

Getting error:

WebDriverException: Message: unknown error: cannot focus element
(Session info: chrome=69.0.3497.100) (Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.13.1 x86_64)

Can someone please help?

1
Please share the html of the upload element? is an input box with button or simple a button ? - Navarasu

1 Answers

0
votes

Choose file has two arguments 1. element locator(this is the place where you choose file or select file option on webpage)
2. Location of the file on your local machine

By reading your script, I understood that you have set focus on incorrect element.

Upload Files
    choose file   //input[@file-model='supplieruploadfile']    {path to file on local machine}
    click element   (//button[contains(text(),'Upload')])[1]