[wtr-general] Re: Trouble testing dynamically-created HTML

2009-08-11 Thread Burdette Lamar

I erred in asking two questions here.  I'll post the second
separately.

On Aug 5, 9:32 am, Burdette Lamar burdettela...@yahoo.com wrote:
 I’ve been having a lot of trouble with stuff that Javascript builds in
 the DOM after the complete HTML page is returned.  I’ve tried to
 counter that with extreme defensiveness.

 For example, this extension to Watir::SelectList is meant to bullet-
 proof SelectList#select against Javascript that’s building the options
 dynamically.  It waits until the desired option is included in the
 select list before trying to select it, thus:

 module Watir

   class SelectList

     # Wait for option, select it, return whether selected.

     alias old_select select

     def select(text)
       Watir::Waiter::wait_until { self.includes?(text) }
       Watir::Waiter::wait_until do
         old_select(text)
         self.selected?(text)
       end
     end

   end

 end

 When my test executes and it tries to select, for example,
 ‘2009.08.03.Mon.16.09.43:Name’, it _occasionally_ causes this failure
 (via RSpec):

 No option with text of 2009.08.03.Mon.16.09.43:Name in this select
 element
 C:/test/watir_extensions.rb:93:in `select'
 snipped traceback
 91      Watir::Waiter::wait_until { self.includes?(text) }
 92      Watir::Waiter::wait_until do
 93        old_select(text)
 94        self.selected?(text)
 95      end

 So one question is:  If self.includes?(text) is true, how can
 old_select fail?

 Another is:  How are other Watir users handling dynamically-created
 HTML?

 Thanks,Burdette
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Testing dynamically-created elements in the DOM

2009-08-11 Thread Burdette Lamar

(I erred in an earlier post by asking two questions in one post.  This
post puts the second question separately.)

Some of the HTML pages I test are modified in the DOM after the HTML
is delivered.

One of the first manifestations of this that I saw was getting an
exception when I tried to select an option in a select list.  When I
put in code to print the number of options in the list, I got 0 even
though I could see many options on my screen.  I found that the
options were built by Javascript after the page is delivered.

I don't know of a way to be sure when all dynamically-created elements
exist, so I don't know when it's safe to try to access them.

Does anyone have a strategy for dealing with this?

Thanks, Burdette

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



[wtr-general] Trouble testing dynamically-created HTML

2009-08-05 Thread Burdette Lamar

I’ve been having a lot of trouble with stuff that Javascript builds in
the DOM after the complete HTML page is returned.  I’ve tried to
counter that with extreme defensiveness.

For example, this extension to Watir::SelectList is meant to bullet-
proof SelectList#select against Javascript that’s building the options
dynamically.  It waits until the desired option is included in the
select list before trying to select it, thus:

module Watir

  class SelectList

# Wait for option, select it, return whether selected.

alias old_select select

def select(text)
  Watir::Waiter::wait_until { self.includes?(text) }
  Watir::Waiter::wait_until do
old_select(text)
self.selected?(text)
  end
end

  end

end

When my test executes and it tries to select, for example,
‘2009.08.03.Mon.16.09.43:Name’, it _occasionally_ causes this failure
(via RSpec):

No option with text of 2009.08.03.Mon.16.09.43:Name in this select
element
C:/test/watir_extensions.rb:93:in `select'
snipped traceback
91  Watir::Waiter::wait_until { self.includes?(text) }
92  Watir::Waiter::wait_until do
93old_select(text)
94self.selected?(text)
95  end

So one question is:  If self.includes?(text) is true, how can
old_select fail?

Another is:  How are other Watir users handling dynamically-created
HTML?

Thanks, Burdette



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