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

How can I find an inner Element

1 Answer 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 19 Apr 2013, 04:42 PM
In an C# Script the following works:
            Element mainContent;
            mainContent = ActiveBrowser.WaitForElement(Pages.Deuba_Relaunch_FR_Navigation.Expressions.Productoverview_Maincontent_Div, 3000, false);        

How can i find an Element in mainContent, for Example an Div ?

It should give me back an HtmlDiv-element like

 HtmlDiv itemCount = Find.ByExpression<HtmlDiv>(new HtmlFindExpression("class=itemCount"));

Thanks for your help




1 Answer, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 22 Apr 2013, 01:58 PM
Hi Michael,

I wrote a simple example against a demo application.

Here is the HTML:

<!DOCTYPE html>
<html>
<head>
<title>Div</title>
</head>
<body>
    <table id="myTable">
        <tr>
            <td>
                <div class="itemCount">Here is my div</div>
            </td>
        </tr>
    </table>
</body>
</html>
 
Here I am locating the table and then I am looking for the div inside of the table:

HtmlTable tab = ActiveBrowser.Find.ById<HtmlTable>("myTable");
HtmlDiv itemCount = tab.Find.ByAttributes<HtmlDiv>("class=itemCount");
Log.WriteLine(itemCount.InnerText);

Here is a video demonstration.

Hope this helps.

Regards,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or