Note that there are some explanatory texts on larger screens.

plurals
  1. POclick_no_wait does not work the second time when autoIt is used to handle the file download box
    text
    copied!<p>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. </p> <p>Environment: OS: Microsoft XP SP2 Ruby : ruby 1.8.6 patchelevel 398 Watir : 1.8.1 </p> <p>Following is the way I am using the control </p> <pre><code>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 </code></pre> <p>Here's the code for downloading the file </p> <pre><code>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, "", "&amp;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 </code></pre> <p>Here's the error which I am getting </p> <pre><code>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 </code></pre> <p>Any help would be appreciated. Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload