uploading a file

512 views
Skip to first unread message

vishnu vasudev

unread,
Jul 12, 2016, 3:29:29 PM7/12/16
to robotframework-users
Hi Experts,
I would like to upload a file to a site from the laptop which i have installed robot framework.

i have used the below keyword

Choose File xpath=//*[@id="attach-file"]/div[1]/fieldset/div/div/label C:/Users/SRN/Downloads/NEALLOCATION${allocations}.png



But its not working with error below

WebDriverException: Message: unknown error: cannot focus element
  (Session info: chrome=51.0.2704.103)
  (Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 6.1 SP1 x86_64)

is there any thing wrong in my command which would have caused this to fail

Regards
Vishnu

dm08

unread,
Jul 12, 2016, 3:49:32 PM7/12/16
to vishnuva...@gmail.com, robotframework-users
Hi,

From you locator I can say that you try to upload file to the label however it should be input[@type=‘file]  

Thanks, 
Dmitriy

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

vishnu vasudev

unread,
Jul 13, 2016, 2:10:41 AM7/13/16
to dm08, robotframework-users
Hi Dmitriy.
Thanks alot.
It worked.

Regards
Vishnu
Message has been deleted

7145...@qq.com

unread,
Feb 28, 2017, 5:14:09 PM2/28/17
to robotframework-users, dmitriy...@gmail.com
Hi Vishnu,
Is it possible to use Choose File to upload file while the element is label type??

Best wishes,
Lewis

在 2016年7月13日星期三 UTC+8下午2:10:41,vishnu vasudev写道:
Hi Dmitriy.
Thanks alot.
It worked.

Regards
Vishnu
On Wed, Jul 13, 2016 at 1:19 AM, dm08 <dmitriy...@gmail.com> wrote:
Hi,

From you locator I can say that you try to upload file to the label however it should be input[@type=‘file]  

Thanks, 
Dmitriy

On Jul 12, 2016, at 12:29 PM, vishnu vasudev <vishnuva...@gmail.com> wrote:

Hi Experts,
I would like to upload a file to a site from the laptop which i have installed robot framework.

i have used the below keyword

Choose File xpath=//*[@id="attach-file"]/div[1]/fieldset/div/div/label C:/Users/SRN/Downloads/NEALLOCATION${allocations}.png



But its not working with error below

WebDriverException: Message: unknown error: cannot focus element
  (Session info: chrome=51.0.2704.103)
  (Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 6.1 SP1 x86_64)

is there any thing wrong in my command which would have caused this to fail

Regards
Vishnu

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

vishnu vasudev

unread,
Mar 1, 2017, 12:22:06 PM3/1/17
to 7145...@qq.com, robotframework-users, dm08
Hi,
I was not able to upload the file with the label.
so i have tried the input[@type=‘file]   to upload the file which worked 

Regards
Vishnu

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Message has been deleted

GAURAV DEORE

unread,
Jun 14, 2018, 8:46:50 AM6/14/18
to nitishk...@gmail.com, robotframework-users
Hi,

I would suggest keep this .png file in your automation framework folders.. then used relative path to choose expected file from respective folder.


 Assume Script folder name : Project1

e.g.  Choose File xpath=//*[@id="attach-file"]/div[1]/fieldset/div/div/label  input[@type='Project1/../InputFiles/NEALLOCATION${allocations}.png']


On Tue, Jun 12, 2018 at 9:48 PM, nitish kamagiri <nitishk...@gmail.com> wrote:
Hi Vishnu,

Do you mean input[@type='C:/Users/SRN/Downloads/NEALLOCATION${allocations}.png]  where file = C:/Users/SRN/Downloads/NEALLOCATION${allocations}.png.


So now the Keywoprd would be 

Choose File xpath=//*[@id="attach-file"]/div[1]/fieldset/div/div/label input[@type='C:/Users/SRN/Downloads/NEALLOCATION${allocations}.png] 


I tried doing this but it did not work. Can you please help me asap. Thanks


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
------------------------------
Warm Regards,
GAURAV S. DEORE.

Christian Rudolf Tan

unread,
Dec 4, 2018, 3:55:39 AM12/4/18
to robotframe...@googlegroups.com
Hello nitish,

I have similar problem, mine passed but it was not able to attach file. but in the log file it shows passed.

Keywords.Attached file   ${LeaveRequestbtnChooseFile}     input[@id='C:\\Users\\Christian Tan\\Documents\\Development\\Salttest\\Resources\\attachment.jpg']


Attached file
[Arguments] ${PELEM} ${filepath}
choose file ${PELEM} ${filepath}



I have similar issue with choose file where my test will pass but no attachment

Mandi B.

unread,
Dec 4, 2018, 5:38:00 AM12/4/18
to robotframework-users
You need to pass two arguments to the 'Choose File' keyword - the element and the file path. 

1. The element - you need the element locator to the input tag. Inspect the 'Browse' button (or 'Choose File' button) on the page that you are working on and locate the <input> tag.
Get the locator to that input tag. 

file_upload.png



In the screenshot, you can see that the 'Choose file' element in my case has an <input> tag with an id of file-upload
2. The actual file path (you can use RF built-in paths to help here) 

So the actual syntax to upload a picture I have in my project workspace to this site would be: 

Choose File   id:file-upload  ${CURDIR}${/}picture.png

As it was mentioned before in this thread, this method works when the element has an input tag. If not, you need to use AutoIT (or Sikuli) library. 

Christian Rudolf Tan

unread,
Dec 4, 2018, 7:57:56 AM12/4/18
to robotframework-users
the attachment failed to upload.

any ways. what is inside ${CURDIR}?

Stefan M.

unread,
Dec 4, 2018, 8:18:16 AM12/4/18
to robotframework-users
Try then 

Choose File  id:file-upload  C:\\Users\\Christian Tan\\Documents\\Development\\Salttest\\Resources\\attachment.jpg

Christian Rudolf Tan

unread,
Dec 5, 2018, 7:08:24 PM12/5/18
to stefan.m...@gmail.com, robotframework-users
thanks its now working!

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages