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

Find.ByExpression to find Sibling elements

3 Answers 186 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 16 Sep 2015, 06:13 PM

So I have something like this:

 

<div class="X">

     <div class="pK">

     <div class = "Z">

           <i class="Target">

pK is what identifies the whole element, this is the only unique thing and I know it going in but that's all I know except that I want to click on i="Target", child of sibling of parent with div class="pK"

So...

Find.ByExpression("class=X", "with child of", "class=pK", "|", "class=Z", "|", "class=Target" )

I think that's where the piece I am missing would go.  Or could I nest them web elements somehow?



Thanks,
Derek


3 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 21 Sep 2015, 10:49 AM
Hello Derek,

Here is an useful article about chained find expressions.

Regarding the find expression that you are looking for, please try the following:

tagname=div,class=X,|,tagname=div,class=Z,|,tagname=i,class=Target

Hope it works for you.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Derek
Top achievements
Rank 1
answered on 22 Sep 2015, 05:41 PM

I think I was not clear.  Your expression here totally ignores the "pK" value, which is the only value in the entire chain off of the first DIV, this pattern exists 100 times on the page but I only want 1 of them and the only way to identify the one I want is by the "pK" value.

This expression just generically finds the "Target", this will return 100 targets instead of 1.

What I am working on now is a loop, iterate through the TagIndex for the top level Div in this example, then search if for the "pk", then once I find it construct an expression using the Iterator variable from the loop to jump directly to that Div tag index.

However, this is going to be excruciatingly slow and I don't have it working yet.  Any superior solution is welcomed.


Derek

 

0
Ivaylo
Telerik team
answered on 25 Sep 2015, 11:46 AM
Hello Derek,

The only way we can provide more complicated and superior scenario is to have access to the control in question.

With the example provided this is the proper way of finding the target element.

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