This is a migrated thread and some comments may be shown as answers.
How to access Title element
2 Answers 16 Views
This is a migrated thread and some comments may be shown as answers.
Saket
Top achievements
Rank 1
Saket asked on 29 Sep 2011, 07:59 AM
Hi,

I have a td element which has a table inside it, the unique identifier for searching my record is the td element
e.g
<td id="abc_1">
<table>
<tr>
<td>
<div>
<ui>
<li title ="abc"
The application auto generates this structure
What i inten to do is access the title element , i use the following
var tableFieldElement = contentFrame.Find.ById<HtmlTableCell>(tablecell)
however the tableFeildElement gives me only <td id="abc_1"> only
Can anyone help me to find the title

Thanks,
Saket

2 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 29 Sep 2011, 03:55 PM
Hi Saket,
   I'm not sure I understand your use case.

In the following definition:
<li title ="abc"
title seems to be an attribute and NOT a separate HTML element.

On the following piece of code:
var tableFieldElement = contentFrame.Find.ById<HtmlTableCell>(tablecell)
I'm assuming that tablecell is a variable with the String "abc_1" stored into it. In this case it's expected behavior that the code returns the element <td id="abc_1">. Check out the Testing Frame's documentation for some guidelines on how to search for elements:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/intermediate-topics/element-identification/finding-page-elements.aspx

It's going to be somewhat trick getting title attribute from the <li> element in your HTML code. Since the <li> element has no other distinguishing features apart from the title you might have to search for it by tagIndex or define a more complex Find Expression. See the tutorials in the user guide for this. Once you've located the element you can easily extract the title attribute:
   HtmlListItem i = Find... //Some find statement
String title=      i.Attributes[0].ToString();

All the best,
Stoich
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Cody
Telerik team
answered on 30 Sep 2011, 10:44 PM
Hello Saket,

You can use code like this to fetch the value of the Title attribute on that buried cell:

HtmlListItem innerCell = contentFrame.Find.ByExpression<HtmlListItem>("id=abc_1", "|", "tagindex=li:0");
Log.WriteLine(innerCell.Attributes[0].Value);

Regards,
Cody
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Saket
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Cody
Telerik team
Share this question
or