Great. I hope others reading can also understand this solution and 
realize that it represents a general solution to a common problem that 
people often ask about.

The problem: How do i find a page element that meets a complex set of 
criteria, possibly including relationships with other objects.

Solution: Don't try to navigate for it yourself. Instead create a 
one-parameter method on Watir::Element that can detect the page element 
you are looking for and then let Watir find it.

Please ask questions if it isn't clear when or how this technique works.

Bret

niartseoj wrote:
> Hello Bret,
>
> Thanks for taking time to help me. You were able to descripher my
> example perfectly and your suggestion works great.
>
> I learned a great deal from this example, thanks again for your time.
>
> On Oct 23, 12:04 pm, Bret Pettichord <[EMAIL PROTECTED]> wrote:
>   
>> Thanks for sharing your code. I *think* i know what you are trying to
>> do, and there is a way to do this in Watir that is elegant and so far,
>> undocumented. I will try to explain it, and if this doesn't work for
>> you, please provide more information about what you want to do (and less
>> about how you are doing it).
>>
>> To me it sounds like you are looking for a cell in a table that has a
>> person's name, and image, and a link. And what you want is the link.
>>
>> This definition should appear at top level:
>>
>>     class Watir::Element
>>       def has_enabled_image_and_text_is name
>>         text == name && self.image(:src, /enabled/).exists?
>>       end
>>     end
>>
>> Put this in your test
>>
>>     t = ie.table(:index, 7)
>>     $atag = t.cell(:has_enabled_image_and_text_is =>
>>     _userid.to_s).link(:index, 1)
>>
>> Please let me know if this works and if I understand what you are trying
>> to do.
>>
>> Bret
>>
>> niartseoj wrote:
>>     
>>> Hello
>>>       
>>> I'm trying to find the method to run in order to determine if a
>>> variarable is a container and if so what sort of container it is.
>>>       
>>> I'm doing this because i have to loop through a table, and identify if
>>> there is a cell that contains a link with a matching name and a
>>> certain type of image object.
>>>       
>>>           t = ie.table(:index,  7)                      # since we
>>> don't have ID's, look at every table
>>>      for i in 1..t.row_count                  # for every row in this
>>> table
>>>       t[i].each do |cell|                    # for every column in this
>>> row, look at its contents
>>>          if cell.text == _userid.to_s
>>>                  if cell.image(:src, /enabled/).exists?
>>>                    $atag = cell.link(:index,1)
>>>                  end
>>>         end
>>>      end
>>>      end
>>>       
>>>  puts $atag.control_type
>>>       
>>> In this code i need to handle if the $atag is set or if it is nill .
>>>       
>>> I'm a neewbie in ruby and watir and i've been going through all the
>>> helpfiles and examples that i can find to do this but no luck,
>>>       
>>> Thanks in advance for any help or direction to my search.
>>>       
> >
>   


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to