require 'watir'

require 'watir\contrib\enabled_popup'

 

include Watir

 

# This method grabs the handle of the window and clicks the button

# you specify by passing in the button text.

# For the File Upload dialog use the user_input parameter

# to supply the path to the file you want to upload.  The button name 

# needs to include the '&' character '&Open' (or &Save for the

# downloading dialog.)

def startClicker( button , waitTime=9, user_input=nil)

  hwnd = $ie.enabled_popup(waitTime)  # get a handle if one exists 

  if (hwnd)  # yes there is a popup

    w = WinClicker.new

    if ( user_input )

      w.setTextValueForFileNameField(hwnd, "#{user_input}")

    end

    sleep 3  # I put this in to see the text being input it is not
necessary to work

    w.clickWindowsButton_hwnd(hwnd, "#{button}")  # "OK" or whatever the
name on the button is

    w=nil    # this is just cleanup

  end

end

 

$ie = IE.new()

 

$ie.goto("C:\\fileupload.html")

$ie.fileField(:name, "fileone").click_no_wait

 

fPath = "file://C:\\mytext.txt"

 

startClicker("&Open", 7, fPath ) # 3rd parameter is optional.

 

Hope this helps,

 

 

--Mark

 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of liucongying
Sent: Tuesday, January 09, 2007 1:01 AM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] how to handle the file download window !

 

I just click the button which can download files, when I click it, the
window of file download pop up, how can I control the window to click
save or open ,or cancle!

---------------------------------------------------------------------

Posted via Jive Forums

http://forums.openqa.org/thread.jspa?threadID=6047&messageID=16942#16942

_______________________________________________

Wtr-general mailing list

Wtr-general@rubyforge.org

http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to