How to handle save as window in Celerity

15 views
Skip to first unread message

Ye Jian

unread,
Jul 22, 2009, 7:46:11 AM7/22/09
to Cukes
Hi,All
    Anybody can tell me how to handle 'save as' window in celerity,like when we download file after click a link,a 'save as' window will be popup,how to click save button of this popup window?
 
Thanks
-Camael

Aslak Hellesøy

unread,
Jul 22, 2009, 7:53:12 AM7/22/09
to cu...@googlegroups.com, Cukes


Hi,All
    Anybody can tell me how to handle 'save as' window in celerity,like when we download file after click a link,a 'save as' window will be popup,how to click save button of this popup window?

Please check the Watir/Celerity documentation/lists for this.

Aslak
 
Thanks
-Camael


jari....@finn.no

unread,
Jul 22, 2009, 7:54:02 AM7/22/09
to cu...@googlegroups.com
Hello Camael

If you have a link/button/whatever to something you want to download, you
can use ClickableElement#download to get the contents as an IO object:

browser.link(:id, 'pdf').download #=> #<IO:...>

If you have a link that triggers a popup window, you can call
ClickableElement#click_and_attach, which will return a new browser instance
with the popup page loaded:

popup_browser = browser.link(:id, 'popup').click_and_attach

So if I understand your situation correctly, you want something like this:

popup_browser = browser.link(:id, 'popup').click_and_attach
io = popup_browser.button(:id, 'save').download
File.open("some_file") { |file| file.write(io.read) }

The #download method was introduced in version 0.0.6.7 of Celerity.

jb

jari....@finn.no

unread,
Jul 22, 2009, 7:56:47 AM7/22/09
to cu...@googlegroups.com


On 22.07.09 13.53, Aslak Hellesøy <aslak.h...@gmail.com> wrote:

Please check the Watir/Celerity documentation/lists for this.

Aslak

Heh, guess I'm not helping you avoid that :)

Camael, please check out the Celerity mailing list at http://rubyforge.org/mailman/listinfo/celerity-users

Reply all
Reply to author
Forward
0 new messages