How to save a system generated file with Robot Framework

1,027 views
Skip to first unread message

sabbir hossain

unread,
Sep 3, 2013, 8:33:51 AM9/3/13
to robotframe...@googlegroups.com
Hello All,

 In my project for "Reporting & Printing"  function i need to save files. Is it possible to save those files by Robot Framework?
Any one can please help me regarding this? here i have attached a file...


Thanks,
Sabbir

RnP.jpg

Kevin O.

unread,
Sep 3, 2013, 11:18:49 AM9/3/13
to robotframe...@googlegroups.com
I think a good approach is to extract the URL of the file you are downloading using keywords like Get Element Attribute and download it outside of the browser. You are not validating the browser's ability to download a file, after all.
Its easy if you can download the file via GET and do not need to save it to disk (can work with it in memory).
Here's a keyword for that simple scenario that returns the file contents as a string:

import urllib2

def get_file(url):
    return urllib2.urlopen(url).read()

The result could then be passed to XML.Parse XML, allowing you do do validation with the XML library.
If you need to do a POST, then it is going to be a bit harder, but still possible.

Message has been deleted

sabbir hossain

unread,
Sep 4, 2013, 1:17:38 AM9/4/13
to robotframe...@googlegroups.com
Dear Kevin,

Thanks for your reply. ...
I have to use only browser IE for my project and it always open as POP UP window.There are two POP UPs ,one is the main window and another POP UP opens for "Reporting & Printing" function From where i have to download the files by clicking on a button. Perhaps i would not be able to download the files coz before downloading there is few validations. Could you please help me bit more regarding this...


Br & Thanks
Sabbir

Kevin O.

unread,
Sep 4, 2013, 11:18:18 AM9/4/13
to robotframe...@googlegroups.com
There are two options I can think of that would work, AutoIt and Sikuli.
AutoIt is Windows-only and there is already a library for it. Sikuli is cross-platform and would probably be a lot harder to use.
One of the downsides of using either of these tools is it becomes quite difficult to use them if you are using Grid.

sabbir hossain

unread,
Sep 6, 2013, 6:38:28 AM9/6/13
to robotframe...@googlegroups.com
Dear Kevin,

Thanks,
I had gone through AutoIt but did not find any keyword which can download files.... can you tell me any specific keyword for saving files?

Br & Thanks
Sabbir


Kevin O.

unread,
Sep 6, 2013, 9:19:43 AM9/6/13
to robotframe...@googlegroups.com
I have never used AutoIt with RF and only once outside RF.
AutoIT comes with a spy tool to help you identify windows and controls.
Someone else would be able to help you much more than I can.

sabbir hossain

unread,
Sep 6, 2013, 9:56:39 AM9/6/13
to robotframe...@googlegroups.com
Dear Kevin,

Thanks ....

Br
Sabbir
Reply all
Reply to author
Forward
0 new messages