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

Defining an element by two attributes?

1 Answer 12 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Reese
Top achievements
Rank 1
Reese asked on 29 Jul 2014, 08:36 PM
Is it possible to define an element of a web page by two attributes? For instance, I can find the element by its innertext

Element imagePage = ActiveBrowser.Find.ByContent(pageNumbers[p],FindContentType.InnerText);

Or I can define an element by part of its element id

Element imagePage = ActiveBrowser.Find.ById("p:p")

But can I define it by using both? The elements themselves are recreated every time the program is run so the only constant is the inner text but that is not enough to differentiate it from other elements on the web page, the only way I can think to differentiate the element is by adding another identification method which will use the first part of the element id, in this case "p", that also remains constant and is unique to that specific element. Any help will be greatly appreciated.

Thanks,
Reese

1 Answer, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 30 Jul 2014, 08:19 AM
Hello Reese,

Thank you for contacting us.

Here is how you can find a div element for example with InnerText and the first part of the ID:

HtmlDiv myDiv = ActiveBrowser.Find.ByExpression<HtmlDiv>("InnerText=Test","ID=~p");

Hope this helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Reese
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or