Title: Re: [Wtr-general] How to click the Windows'Save'buttonwhendownloading a file

Try this, it works on my computer.  You may need to change the required path to your Watir install directory.  Change the “<location to save to>” to some save path of your choosing

 

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__

require 'C:\watir\unittests\setup'

require 'watir'

require 'win32ole'

include Watir

 

docName = "XUS8120873file1.pdf (19 Kb)"

 

testSite ="http://www.stickyminds.com/r.asp?F=DART_9601"

 

$path = "C\:\\<location to save to>\\"  #e.g. "C\:\\watir_bonus\\working\\"

 

$ie = IE.new

puts "Beginning of Example:  Sticky Minds"

sleep 1

puts "Step 1: go to the test site:  " + testSite

$ie.goto(testSite)

 

$ie.link(:text, "XUS8120873file1.pdf (19 Kb)").click

 

$autoit = WIN32OLE.new("AutoItX3.Control")

$autoit.WinWait("File Download", "Do you want to open or save this file?", 3)

$autoit.ControlClick("File Download", "Do you want to open or save this file?", "&Save")

$autoit.WinWait("Save As", "Save &in", 3)

$autoit.ControlSend("Save As", "", "Edit1", "#{$path}temp.pdf")

$autoit.ControlClick("Save As", "Save &in", "&Save")

 

--Mark


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Müller Michael (BB)
Sent: Thursday, September 15, 2005 5:42 AM
To: [email protected]
Subject: AW: [Wtr-general] How to click the Windows'Save'buttonwhendownloading a file

 

It doesn't work. I don't know what to do. I checked the documentation and tried several different things.

 

I also started AUInfo.exe and the Controls and Information are exactely the same as in your example script.

I've inserted also statement to give out if a function was executed. The logfile then has all the Statements inside, as all function where executed properly, but also a Error is stated:

 

WIN32OLERuntimeError: Unknown property or method 'document'

      HRESULT error code:0x800706ba

          The RPC Server is unavailable

c:\ruby\.......\watir.rb: in 'method_missing'

c:\ruby\.......\watir.rb: in 'document'

c:\ruby\.......\watir.rb: in 'getLink'

c:\ruby\.......\watir.rb: in 'initialize'

c:\ruby\.......\watir.rb: in 'new'

c:\ruby\.......\watir.rb: in 'link'

c:\watir_bonus\...\document_lib.rb  (stating the line number where the error started, is the next fnuction after the autoit functions)

 

 


Von: [EMAIL PROTECTED] im Auftrag von Dave Burt
Gesendet: Do 15.09.2005 11:21
An: [email protected]
Betreff: Re: [Wtr-general] How to click the Windows'Save'buttonwhendownloading a file

Mueller schrieb:
> Thanks for the answer. I tried this approach, but the Windows opens and
> nothing
> happens. the scripts is seems to "wait" for an action but nothing happens.
> When I
> cancel the script no error is reported in the log file.
>
> Any Idea why it doesnt work? Do i have to install some additional components?

Try typing the script line by line into IRB, see where it stops working.

If it's not getting a control or window (perhaps because you have a different
version of IE or Windows to me, and the text or controls in the windows are
different), you might have to change some of the parameters I'm passing to
WindowWait or ControlClick etc. You can download AutoIt from
http://www.autoitscript.com/autoit3/downloads.php - get the ZIP, and just pick
AU3Info.exe out of it - if you run it, then cause the dialogs to be shown, that
will tell you the info you need for your script.

Cheers,
Dave

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to