Bret,
I've been using Watir for about 6 months now and I may have a fix for
this problem that I just wrote today for 1.4.1 and re-wrote tonight
after finding the newer development sources. I wrote a to_identifier()
method which generates a string containing the full classes to find the
current object to click. This can then be run in another thread to do
the click_no_wait(). Because the application I'm working on doesn't
always have a unique title I also modified the 1.4
attach_browser_window() function to also allow attaching to a running IE
identified by :hwnd in addition to the normal :name or :title. This
*guarantees* that you are clicking in the same window that your current
Watir process is working with.
Here's an IRB log of how it works after digging down to a button inside
nested framesets:
irb(main):001:0> require 'watir'
=> true
irb(main):002:0> include Watir
=> Object
irb(main):003:0> (added to_identifier method here)
irb(main):022:0> my_ie = IE.attach(:title, /SAM/)
irb(main):023:0> frame1 = my_ie.frame('Main')
irb(main):024:0> frame2 = frame1.frame('workarea')
irb(main):025:0> button = frame2.button(:id, 'btnCont')
irb(main):026:0> button.to_identifier
=> "IE.attach(:hwnd, 198076).frame(:name, 'Main').frame(:name,
'workarea').button(:id, 'btnCont')"
irb(main):027:0>
This method should be able to be added to the Containers module so it
should work fine with elements in nested frames like above.
def to_identifier
current_object = self
array = []
# generate a string to identify the current object, suitable for
passing to
# an external process or thread for click_no_wait.
while current_object and !current_object.instance_of?(Watir::IE)
parent_object = current_object.instance_variable_get("@container")
class_string = current_object.class.to_s.sub('Watir::', '').downcase
how_string = current_object.instance_variable_get("@how").inspect
what_string = current_object.instance_variable_get("@what")
# Get object string (like "Button(:id, '<button id>')"
array <<
"#{class_string}(#{how_string}, \'#{what_string}\')"
current_object = parent_object
end
array << "IE.attach(:hwnd, #{current_object.ie.HWND})"
array.reverse.join('.')
end
This is NOT a complete solution, as I didn't look at images yet, only
the buttons and links. Here's the snippet I added to
attach_browser_window() in the case statement to allow to attaching to
an IE instance by :hwnd:
when :hwnd
# find window by HWND
log " hwnd is: #{aWin.HWND}"
ieTemp = aWin if (what == (aWin.HWND))
David Schmidt
[EMAIL PROTECTED]
--
Yes, this problem will need to be fixed before we release Watir 1.5.
Bret
On 4/28/06, Rosalind de Vera < [EMAIL PROTECTED]> wrote:
Hello,
I have a link in a frame that brings up a _javascript_
popup-up. When I try to use click_no_wait, I get the
following error:
irb(main):015:0> ie.frame("topFrame").link(:text,
"Reset Settings").click_no_wait
NoMethodError: undefined method
`eval_in_spawned_process' for
#<Watir::Frame:0x2d0bf30>
from
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.945/./watir.rb:2293:in
`click_no_wait'
from (irb):15
Will this be fixed at some point? I saw a posting on
March 24 by lyoungz in the openqa.org forum asking
about the same problem, but I didn't see a response.
Thank you,
Rosalind
_______________________________________________
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