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

Jquery style css selectors

1 Answer 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 03 Jan 2012, 03:35 AM
Hi

I am currently working on a Poc for the testing suite and testing framework.  I had a question about how to query the elements.

I want to query elements using a jquery style selector eg find me elements which have a class of x and are within elements of type p I tried to do this using the following :

HtmlControl cc = this.TestFramework.Find.AllControls<HtmlControl>().Where(c => c.CssClass == ".x, p").FirstOrDefault();
This returned nothing which is what I expected.

To find these kinds of elements at the moment I have to do something like the following:

Element element = this.TestFramework.Find.AllControls<HtmlDiv>().Where(c => c.CssClass == "formColWidth01").First().ChildNodes[0].ChildNodes[0];

Do you have any plans to support jquery style selection for elements any time in the future?

Regards

Joe

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 04 Jan 2012, 10:22 PM
Hi Joe,

At this time we do not have plans to implement jQuery style selection. Instead we have our own Find Expressions that are equivalent, if not better than jQuery style selection. Using our find expression the equivalent code looks like this:

// Find all anchor tags having class=x
ReadOnlyCollection<Element> ElementList1 = ActiveBrowser.Find.AllByExpression("class=x", "tagname=a");
// OR
// Find all anchor tags having class=x
ReadOnlyCollection<HtmlAnchor> ElementList2 = ActiveBrowser.Find.AllByExpression<HtmlAnchor>("class=x");

All the best,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or