Dear Ethan,

We had to do this because the ".text" method in firewatir removes all
the newlines before returning the text while in watir it returns the
text with newlines. In certain scenarios, we need to split the
returned text on newline to extract the required text which was
impossible using the .text method of firewatir. :(

If you have a better way of doing this, kindly help us out...

Thanks,
Betsy Joy.

On Feb 17, 10:09 pm, Ethan <[email protected]> wrote:
> Why is this necessary? This looks very fragile and error-prone to me. What
> problem does this solve? Returning text without tags and html entities is
> the point of the #text method, and the code that does this (which is in
> firefox itself) is much more robust.
>
>
>
> On Wed, Feb 17, 2010 at 01:50, Betsy <[email protected]> wrote:
> > Hi all,
>
> > We had tried to build a wrapper around the ".text" method in FireWatir
> > as below:-
> > #obj is the object we want to fetch the text of
> > htmlIp= obj.html
> >    htmlbrs=htmlIp.split("<br>")
> >    textIp= obj.text
> >    finalstr=""
> >    for i in 0..htmlbrs.length-1
> >      #cleaning of tags
> >      tagCounter=0
> >      htmlPart=(htmlbrs[i]).split('')
> >      htmlPart2=''
> >      for j in 0..htmlPart.length-1
> >        if htmlPart[j] == "<"
> >          tagCounter=tagCounter+1
> >        elsif htmlPart[j] == ">"
> >          tagCounter=tagCounter-1
> >        elsif tagCounter == 0
> >          htmlPart2=htmlPart2+htmlPart[j]
> >        end
> >      end
> >      #checking for the text
> >      if textIp.include? htmlPart2 then
> >        if i==0 then
> >          finalstr=htmlPart2
> >        else
> >          finalstr=finalstr+"\n"+ htmlPart2
> >        end
> >      end
> >    end
>
> > The final text is returned in the variable - "finalstr".
>
> > This successfully cleans up any extra tags that are returned in the
> > text. This fails when the extra characters in the returned text are
> > not tags rather they are characters like "&amp", "&nbsp" etc. Kindly
> > advise as to how to incorporate the cleaning of the text with respect
> > to the same.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Watir General" group.
> > To post to this group, send email to [email protected]
> > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > To unsubscribe from this group, send email to
> > [email protected]<watir-general%2bunsubscr...@goog 
> > legroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/watir-general

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
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