Hi, I made the changes as per the suggesstion.Below find my modified
script
But my script gets ended once the file starts downloading. The script
is not handling "ai.WinWait("Download complete", "", 5)
  ai.ControlClick("Download complete", "", "Close")"
Please help on this. I am using watir-1.6.2

require 'watir'
require 'win32ole'

$ie = Watir::IE.new
$ie.goto("http://localhost/dportal";)
$ie.image(:name, 'toplogo_nav_04_off').click
$ie.link(:text, 'Hitach product').click
$ie.link(:text, 'File size 220 MB').click_no_wait

    ai = WIN32OLE.new("AutoItX3.Control")
    ai.WinWait("File Download", "", 5)
    ai.ControlFocus("File Download", "", "&Save")
    sleep 1
    ai.ControlClick("File Download", "", "&Save", "left")
    ai.WinWait("Save As", "", 5)
    sleep 1
    begin_time=Time.now
    ai.ControlSend("Save As", "", "Edit1","login.csv")
    ai.ControlClick("Save As", "", "&Save", "left")
    ai.WinWait("Download complete", "", 5)
    ai.ControlClick("Download complete", "", "Close")
    end_time=Time.now
    p (end_time - begin_time).to_s

Thanks
Maumita


On Feb 11, 11:46 pm, orde <ohil...@gmail.com> wrote:
> Is there a Download Complete prompt/popup?  If so, you could wrap this
> section of solution #2, and it will give you an approx. download
> time.
>
> Otherwise, you might be able to use the File class (e.g. see if the
> downloaded file exists?  is the size 220MB?).
>
> ###
> begin_time=Time.now
>     ai.ControlSend("Save As", "", "Edit1",filepath)
>     ai.ControlClick("Save As", "", "&Save", "left")
>     ai.WinWait("Download complete", "", 5)
>     ai.ControlClick("Download complete", "", "Close")
> end_time=Time.now
> download_time = time_start - time_end
> ###
>
> Hope it helps.
>
> On Feb 11, 2:20 am, Maumita <maumita.majum...@gmail.com> wrote:
>
> > require 'watir'
> > require 'win32ole'
> > $ie = Watir::IE.new
> > $ie.goto("http://localhost/dportal";)
> > $ie.image(:name, 'toplogo_nav_04_off').click
> > $ie.link(:text, 'Hitach product').click
> > $ie.link(:text, 'File size 220 MB').click_no_wait
>
> > prompt_message = "Do you want to open or save this file?"
> > window_title = "File Download"
> > save_dialog = WIN32OLE.new("AutoItX3.Control")
> > sleep 1
> > save_dialog_obtained =
> > save_dialog.WinWaitActive(window_title,prompt_message, 25)
> > save_dialog.ControlFocus(window_title, prompt_message, "&Save")
> > sleep 1
> > save_dialog.ControlClick(window_title, prompt_message, "&Save")
> > saveas_dialog_obtained = save_dialog.WinWait("Save As", "Save&in", 5)
> > sleep 1
> > begin_time=Time.now
> > path = File.dirname("D:/ruby/log/").gsub("/" , "\\" )+ "\\" +
> > "login.csv"
> > save_dialog.ControlSend("Save As", "", "Edit1",path)
> > save_dialog.ControlClick("Save As", "Save &in", "&Save")
> > end_time=Time.now
> > download_time = time_start - time_end
>
> > But my scripts exist when the file starts downloading.
> > Please help on this.This is urgent for my project to measure the file
> > download time.
> > Is there any other way to do this?
>
> > Thanks in advance
> > Maumita
>
> > On Feb 11, 2:14 am, orde <ohil...@gmail.com> wrote:
>
> > > I've used solution #2 onhttp://wiki.openqa.org/display/WTR/File+Downloads.
>
> > > You should be able to modify that code to get an approximate download
> > > time:
>
> > > time_start = Time.now
> > > # code
> > > # code
> > > time_end = Time.now
> > > download_time = time_start - time_end
>
> > > Hope it helps.
>
> > > orde
>
> > > On Feb 10, 1:30 am, Maumita <maumita.majum...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > Is this possible to write a watir script that should download a file
> > > > from website to locally and also to measure how long it takes to
> > > > download the file.
> > > > This is a requirement in my project. The main idea is to measure the
> > > > download time of a file.
> > > > Please suggest if there is any way to do this.
> > > > Thanks in advance.
>
> > > > Maumita

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to