This is a migrated thread and some comments may be shown as answers.

How to using Find.ByContent

1 Answer 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lucy
Top achievements
Rank 1
Lucy asked on 12 Jan 2012, 05:23 AM
Hi,
I am new in this area. Pls help me with this problem.
I have a div like below:
<div>
    Hello
    <br/>
    world
</div>

How can i find above <div> by using Manager.Current.ActiveBrowser.Find.ByContent<HtmlDiv>("Hello<br/>world")
It's alway return null
If remove <br/> --> find.ByContent("Hello world") --> it's ok

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 12 Jan 2012, 04:24 PM
Hello Lucy,

Here is more information on Find.ByContent. Here is sample code:

HtmlDiv d = Find.ByContent<HtmlDiv>("p:Hello");

You can also use Find.ByExpression. Here is an example of that:

HtmlDiv d = Find.ByExpression<HtmlDiv>("innermarkup=Hello<br>world");

This also works:

HtmlDiv d = Find.ByExpression<HtmlDiv>("innertext=Helloworld");


This blog post explains the difference between content validation types.

Kind regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Lucy
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or