Hi every1,
I am facing the problem where I call the method click_no_wait on a
control which displays a "File Download" box. It works fine for the
1st time. i use Auto It to handle the file download box and save the
file at a particular location. Now, when I try to use the
click_no_wait on the same control, it won't display the File Download
box, but If i refresh the browser before calling the click_no_wait, it
will display the File Download box. So, my question is that is it the
case that Auto It is not being released and thus click_no_wait cannot
find the control or is there something wrong with the implementation
of the click_no_wait method.
Environment:
OS: Microsoft XP SP2
Ruby : ruby 1.8.6 patchelevel 398
Watir : 1.8.1
Following is the way I am using the control
def click_export_button
control = browser.button(:id,'export-button')
$DEBUG = true
#browser.refresh #- If this line is not commented, the dialog
appears
control.click_no_wait #-- I replace click_no_wait with click and/or
click! and the code freezes, so the control is found
download_file("C:\\test.csv")
$DEBUG = false
end
Here's the code for downloading the file
def download_file(filePath = nil)
autoIt = WIN32OLE.new("AutoItX3.Control")
timeout = 10
fileDownloadWindowTitle = "File Download"
handle = autoIt.WinWait(fileDownloadWindowTitle, "Do you want to
open or save this file?", timeout)
retVal = nil
unless (handle.eql? @autoItError)
autoIt.WinActivate(fileDownloadWindowTitle)
autoIt.ControlClick(fileDownloadWindowTitle, "", "&Save")
saveWindowTitle = "Save As"
windowHandle = autoIt.WinWaitActive(saveWindowTitle, "",
timeout)
if (windowHandle == 1)
retVal = save_file(saveWindowTitle, autoIt, filePath) #--
function to save the file to the location
end
else
puts "Unable to download the file"
end
autoIt.ole_free
return retVal
end
Here's the error which I am getting
ruby -e "$:.unshift('c:/ruby/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/
watir/win32ole').unshift('c:/ruby/lib/ruby/gems/1.8/gems/
commonwatir-1.8.1/lib').unshift('c:/ruby/lib/ruby/gems/1.8/gems/
firewatir-1.8.1/lib').unshift('c:/ruby/lib/ruby/gems/1.8/gems/
watir-1.8.1/lib');require 'c:/ruby/lib/ruby/gems/1.8/gems/watir-1.8.1/
lib/watir/core';Watir::Button.new(Watir::IE.attach(:hwnd,
6751822), :unique_number, 3).click!();"
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/watir/element.rb:58:in
`assert_exists': Unable to locate element, using :unique_number, 3
(Watir::Exception::UnknownObjectException)
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.8.1/lib/watir/
element.rb:275:in `click!'
from -e:1
Any help would be appreciated.
Thanks in advance
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]