yeap, click! also works for me. but the reason why I want to figure out why
click_no_wait does not work is that I want to use select_no_wait function (I
am testing on a dropdown control and while you select the dropdown control,
it will pop up download file page),
select_no_wait is the function i got from
http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups (iteam 6)
but it seems does not work. It can not trigger the select operation, just
like click_no_wait does not trigger click operation. I think they have the
similar root cause. do you have some ideas?

#sample code#
#select_no_wait method for select lists - needed for popups resulting from
select lists
module Watir
    class Element
        #select_no_wait - selects a drop-down element spawning a new
process.
        #this is needed to close potential pop-ups that select drop-down can
trigger.
        def select_no_wait(item)
            assert_enabled
            puts "calls select_no_wait function"
            highlight(:set)
            object = "#{self.class}.new(self,
:unique_number,#{self.unique_number})"
            @page_container.eval_in_spawned_process(object +
".set('#{item}')")
            highlight(:clear)
        end
    end
end

def save_file(filepath)
    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
    ai.ControlSend("Save As", "", "Edit1",filepath)
    ai.ControlClick("Save As", "", "&Save", "left")
    ai.WinWait("Download complete", "", 5)
    ai.ControlClick("Download complete", "", "Close")
  end

#main code#
$ie.select_list(:id,"_id0:actions").select("Generate Default Template")
save_file("C:\\file1.txt")


2009/2/13 jensen2525 <jensen2...@gmail.com>

>
>
> I ran into a similar issue and was able to work around it by calling
> click! instead of click or click_no_wait.  We're not using SproutCore
> so this may not be relevant to your issue.
>
> ## snip
>          # Click on the Export button then Save the file as an
> artifact
>          export = browser.button(:id, "exportButtonId")
>          export.click!
>          popup_save_file artifact_filename
> ## end snip
>
> ## snip
>    def popup_save_file(filename, wait_time = 10)
>      begin
>        autoit = WIN32OLE.new("AutoItX3.Control")
>
>        # Wait for the "File Download" dialog
>        autoit.WinWaitActive("File Download", "", wait_time)
>
>        # Click on the Save button
>        autoit.ControlFocus("File Download", "", "&Save")
>        sleep 1
>        autoit.Send("S")
>        autoit.ControlClick("File Download", "", "&Save")
>
>        # Wait for the "Save As" dialog, enter the filename and click
> Save
>        autoit.WinWaitActive("Save As", "", wait_time)
>        autoit.Send(filename)
>        autoit.ControlClick("Save As", "", "&Save")
>
>        # Wait for the "Download complete" dialog and Close it
>        autoit.WinWaitActive("Download complete")
>        autoit.WinClose("Download complete")
>      rescue
>        @@logger.warn "Error occurred while saving file: #{$!}"
>      end
> ##end snip
>
>
> Good luck.
>
>
>
> On Feb 11, 8:11 pm, Bill Xu <xulei8823...@gmail.com> wrote:
> > Hi
> >    The Thread.new function seems still could not solve the problem.
> > (click_no_wait still could not work for me, the)
> > see following simple code:
> > ####code#####
> > downloadlink  = $ie.link(:text,"SAMPLE.CSV")
> > thr = Thread.new {
> >   downloadlink.fire_event("onMouseDown")
> >   downloadlink.fire_event("onMouseUp")}
> >
> > downloadlink.click_no_wait
> > save_file("C:\\file.txt")
> > ####code end#####
> > Note that the link is chosen but not clicked.
> >
> > 2009/2/11 LFIdnl <sraniim...@gmail.com>
>  >
> >
> >
> > > Run you part of code in new thread:
> >
> > > thr = Thread.new {
> > >   your_object.fire_event("onMouseDown")
> > >   your_object.fire_event("onMouseUp")
> > > }
> > > sleep(5) #Waiting for end of execution of thread
> > > #continue your test
> >
> > > On 26 янв, 23:25, Bill Mosteller <w...@greatdecals.com> wrote:
> > > > The application situation is that the user is about to discard
> unsaved
> > > > work.  A dialog box appears titled "Windows Internet Explorer" saying
> > > > "Are you sure you want to delete the selected Email?" with buttons
> > > > "OK" and "Cancel".
> >
> > > > I thought my prayers were answered for this when I found:
> > >http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups
> >
> > > > While it proposes five solutions to the problem, solutions 3 thorugh
> 5
> > > > require the use of .click_no_wait.  I'm testing a SproutCore
> > > > application, and .click doesn't work, so .click_no_wait doesn't,
> > >  > either.  (I'm using .fire_event("onMouseDown") followed by
> .fire_event
> > > > ("onMouseUp") to click on things.
> >
> > > > So I tried solutions 1 and 2 in the article, and while I got both to
> > > > execute without errors in my application, neither approach dismisses
> > > > my modal dialog box.
> >
> > > > Thankis.
> > > > Bill Mosteller
> > > > Eloqua
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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