Ha!  Funny you should ask.. I just solved the same problem last week..  It took me a few days to figure it out, so I'm happy to share it with you.

On 14/02/06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:
Using SpySmith the content of this link looks like this.

Active Element: [A], Index: [417]
<A class=universalLink href=''>
<SPAN class=b>Ingleside</SPAN> </A>


When I run the show_spans() command on the desired frame, I see something like the following:
----
Found 12 span tags
1   id=_ctl0_BorrowerList1_lblBorrowerListTitle      class=
2   id=      class=
3   id=      class=HeaderHiliteClass
4   id=      class=
5   id=      class=GroupClass
6   id=      class=
7   id=      class=GroupClass
8   id=      class=
9   id=      class=GroupClass
10   id=      class=
11   id=      class=
12   id=      class=
----

Unfortunately the Span method only (currently) allows for the following 3 "how" attributes: :index, :id, :name, but I would need something like the ":text" attribute to identify it by the text contained within the Span tags.

I decided to capture the text contents to a hash/dictionary array to associate them with their index numbers.  That way I can use the Span method by :index to flash and click the desired span tags.  Here's my code:
----
   # variables
   $C_Tree_h = Hash.new()
   last_item = $ie.frame("ContextTree").spans.length - 3   # This frame always has 3 extra Spans at the end

   # Populate the Hash/Dictionary with the index numbers and text contents of every other Span in this Frame
   3.step(last_item, 2)  { |x| $C_Tree_h[x] = $ie.frame("ContextTree").span(:index, x).text() }
  
   # then navigate to the desired spot with:
   $ie.frame("ContextTree").span(:index, $C_Tree_h.index("Span Tag Text")).click

----

The first 3 lines (ignoring the comments) are setup and I only need to run them once on the frame when I enter the page.  The last command I can run as many times as I want to navigate the Context Tree with the unidentifiable Span tags.

I plan to make a method out of these lines to clean up the code a bit, but I'm currently busy testing another project.  I'll get to it later.

Hope that helps.  Cheers.
Paul.


P.S., FEATURE REQUEST:
If I could make a request to improve the Span method, it would be to add ":text" to the "how".  That would be sweet!

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to