[Webtest] VerifyText: How to handle nbsp?

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Wed, 20 Dec 2006 04:24:14 -0800 (PST)

Hi John,

verifyText works on the content received form server. EXACTLY on that
meaning for instance that no parsing is performed.
I'm not sure if it would make sense to provide a facility to perform
verifications on the "text representation" of the page as it is already
possible with xpath: <verifyXPath xpath="//body/text()" text="Confirm
Password" regex="true"/>. (See
http://webtest-community.canoo.com/jira/browse/WT-251 concerning the misuse
of regex attribute here).

When you write <verifyText text="Confirm&nbsp;Password:"/> the &nbsp;
entitiy get resolved for the Ant file where it is probably not defined and
the text becomes "ConfirmPassword:". You probably want to use <verifyText
text="Confirm&amp;nbsp;Password:"/>. To avoid fighting against entities in
attribute values, you can write your text in a property file and use the
properties in your test:


and after loading the properties you can use
<verifyText text="${some.text}"/>


John and Pip wrote:
> Hi All,
> VerifyText does not work in the most intuitive way (from my non-techie
> point
> of view). It is called verifyText not verifyHTML but it actually seems to
> do
> the latter.
> This is a particular problem for nbsp e.g. my page appears to say "Confirm
> Password" but the HTML is actually "Confirm&nbsp;Password:".
> If I put <verifyText text="Confirm Password:"/>  it fails but if I put the
> horrible <verifyText text="Confirm&nbsp;Password:"/> it also fails! With
> the
> result showing:
>                 <parameter name="taskName" value="verifyText"/>
>                 <parameter name="text" value="ConfirmPassword:"/>
>                 <result>
>                     <failed duration="15"/>
>                 </result>
> 1) Is there a workaround that will let me handle nbsp somehow, perhaps
> similar to the way I have to handle strings of text that have a word
> bolded
> where I would put for example <verifyText text="&lt;b&gt;Check:&lt;/b&gt;
> have you filled in all sections marked"/>?
> 2) Can anything be done to improve this, because verifyText is really the
> key validation tool for beginners / non-techie users and this behaviour is
> at best confusing. Hopefully I've just missed something (see note re web
> site below). I think the ideal solution is for verifyText to strip out all
> tags from the target and to replace all nbsp with a simple space before
> comparison. I believe WebTest uses HTMLUnit which uses NekoHTML to convert
> the html to xml, so I guess it would have to hook in here or just after
> this
> process as the whole page would need to be converted into a true text
> version if verifyText was to work the way I think it should...?
> Any advice would be most appreciated.
> regards,
>         john

View this message in context: http://www.nabble.com/VerifyText%3A-How-to-handle-nbsp--tf2845084.html#a7989189
Sent from the WebTest mailing list archive at Nabble.com.