Thanks johnssn, it worked.

Cheers,
S

On Monday, 18 July 2016 17:21:47 UTC-7, johnssn wrote:
>
> probably nicer ways are doing it but think this'll work
>
> index = nil
> b.divs(:class, 'grid').each_with_index do |div, idx|
>   index = idx if div.text =~ /text6/
>   break if index
> end
>
>
> ------------------------------
> *From:* Soori <[email protected] <javascript:>>
> *To:* Watir General <[email protected] <javascript:>> 
> *Sent:* Monday, July 18, 2016 2:05 PM
> *Subject:* [wtr-general] How to identify the index of an element by text
>
> I have a scenario where there is a grid of elements with same class name. 
> I need to identify the element position using index.
>
> For example:
>
> <html>
> <body>
> <div class="grid"><p>text1</p></div>
> <div class="grid"><p>text3</p></div>
> <div class="grid"><p>text4</p></div>
> <div class="grid"><p>text23</p></div>
> <div class="grid"><p>text6</p></div>
> <div class="grid"><p>text88</p></div>
> <div class="grid"><p>text3</p></div>
> </body>
> </html>
>
>
> in the above example,  I need to find the index of the div for "text6". 
> Can you please help me how I can do this using watir?
>
> /S
>
> -- 
> -- 
> Before posting, please read http://watir.com/support. In short: search 
> before you ask, be nice.
>  
> [email protected] <javascript:>
> http://groups.google.com/group/watir-general
> [email protected] <javascript:>
>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to