Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Unable to locate Page Element by Find.ByXPath

$
0
0

Hello,

I'm having trouble with using Find.ByXPath function in the Test Studio api.

 

<li class="k-item" role="treeitem" aria-selected="false " data-uid="bec31be9-e618-43fd-8060-a7df0c2c8e14">
<div class="k-mid">
<span class="k-icon k-plus" role="presentation"></span>
<span class="k-checkbox-wrapper" role="presentation">
<input tabindex="-1" class="k-checkbox" id="_bec31be9-e618-43fd-8060-a7df0c2c8e14" type="checkbox"/>
<label class="k-checkbox-label" for="_bec31be9-e618-43fd-8060-a7df0c2c8e14"></label></span>
<span class="k-in">Checkbox Node Text</span>
</div></li>

The problem with locating HtmlControl started with having the dynamic IDs that are generated by Kendo. They change all the time, so we need to find a way to locate the controls without using IDs. I talked with Dev team, and it concluded it is not feasible to change these IDs or add unique name tags.

In this case, I want to check the checkbox of "Checkbox Node Text". I thought xpath maybe a good way to do it by relatively searching from the Span Tag of "Checkbox Node Text".

The Find.ByXpath function works partially but not when I try to traverse relatively. Maybe my xpath syntax is off, but here is what I tried


First:
Element hc = Pages.MYPage0.FrameReal.Find.ByXPath("//span[text()='Checkbox Node Text']");
This works. It finds the correct element and I can operate on it.

Second:
Element hc = Pages.MYPage0.FrameReal.Find.ByXPath("//span[text()='Checkbox Node Text']/preceding-sibling::span[@class='k-checkbox-wrapper']/child::input");

This doesn't work. Null object.

Third:
Ultimately, this is what I want to get:
Element hc = Pages.MYPage0.FrameReal.Find.ByXPath("//span[text()='Checkbox Node Text']/preceding-sibling::span[@class='k-checkbox-wrapper']/child:input");

This doesn't work. Null object.

I have tried many combinations. For some reason, the relative traverse in xpath such as parent, child, preceding-sibling, etc not being processed.

I appreciate your advice! Thank you!

 

 


Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>