This is what I did to the goto method:
File Name: watir_mixin.rb
*****************************
module WatirMixin
def goto_no_wait(url)
# These are the contents of the Watir::goto method, without the "wait" call
@ie.navigate(url)
# I also left of the explicit return value because I don't use it
end
end
*****************************
Then, in my test case:
*****************************
require '../../watir_mixin.rb'
require 'watir'
include Watir
class IE
include WatirMixin
end
class Watir::Frame
include WatirMixin
end
ie = Watir::IE.new
ie.goto_no_wait("http://site_with_popup_during_load.com")
****************************
I think you can do almost the same thing with a mixin module for the
SelectList class:
Find the class in the watir.rb file. Find the select(item) method
(which calls another method, to complicate things). Copy the contents
of the method with the guts of select(item).
In your mixin module, define a new method called select_no_wait(item)
or something similar. Paste in the contents from the previous
paragraph. Delete the @container.wait line. And you should be good
to go.
Past results are no guarantee of future performance, etc. Also, using
mixins like this, I believe you run a risk of getting stepped on by
methods added to future releases of Watir that happen to have the same
name as methods you have defined in mixins.
Questions for the list:
1) Is there an easier way to do this?
2) If not, what with the growing popularity of javascript events
triggered by such things as list selection, button clicking, etc,
would it be a popular idea to start defining a framework for alternate
behaviors like "no_wait" of action methods like click, goto, select,
etc?
One suggestion: All action methods take an optional hash as a
parameter, allowing for click(:no_wait => true) to have the same
behavior as click_no_wait. In Akash's case, he could use select(item,
:no_wait => true). I'd be happy to contribute some test cases if this
sounds like a decent approach.
Ethan
On 12/14/06, Ethan Jewett <[EMAIL PROTECTED]> wrote:
> Akash,
>
> Hopefully someone has a simpler solution, but my solution was to mixin
> (using a module) a new method to the offending class (in your case
> "SelectList") called select_no_wait(item). The contents of this
> method would be the same as the select(item) method, but without the
> @container.wait.
>
> My problem was with the IE.goto method, not with list selection, so
> the execution won't be quite the same, but the idea is there.
>
> I don't have much time right now, but if no one responds with another
> fix within the next 12 hours or so, I'll try to post the code that
> should do that job.
>
> Ethan
>
> On 12/14/06, Akash <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I am getting a javascript pop up after i select a value from some drop down
> > list using the select_list method. Since i can not use click_no_wait for a
> > list, how am i supposed to handle the pop up.
> > Moreover this pop up generates from a modal window and that has added to my
> > woes.
> > Can anyone please provide a solution for it.
> > ---------------------------------------------------------------------
> > Posted via Jive Forums
> > http://forums.openqa.org/thread.jspa?threadID=5778&messageID=16178#16178
> > _______________________________________________
> > 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