Forum Discussion
Hi,
This behaviour is explained in the https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/page/findchildbyxpath-method-page-object.html#result-value help topic section. Namely:
If several elements match the search condition, the function returns the first found object that resides in the Object Tree. If none of the found objects resides in the Object Tree, the function returns the first element from the found set.
The above means that some or all objects found by .EvaluateXPath() are absent in the Object Tree and thus they are not wrapping objects provided by TestComplete (containing the .FindChildByXPath() method) but native DOM objects and you can use only native methods provided by DOM for the given found object.
Note: the above means that not only .FindChildByXPath() method is absent for the native DOM objects, but none of methods and properties that are provided by TestComplete. For example, objDate.Exists cannot be used as well.
Thanks for the replay.
In that case how can I get properties of some child object created by FindChildByXPath with xpath. For example,
if I have multple dom with a class name in the dom, I need to check the some properties inside object with xpath
<ul> <li class = "some Class"> <span class = "some calss2"> text </span> </li> <li> ... </li> ... </ul>
now I am creating object by using //li[@class='val']
In case if I need use childobject, of //span[@class='val'] in each object, how can I do the same with Testcomplete tool
- AlexKaras6 years agoChampion Level 3
Hi,
HTML markup provided by you is very poor one because it does not contain any stable unique identifier.
If you really need to work with web pages that generate markup like you've provided, then you may do it this way:
-- Check if the found object is TestComplete wrapping one. This can be done using the code like this:
if (aqObject.IsSupported(<object>, 'Exists')) then // this is TestComplete object
-- If the found object is TestComplete wrapping one, you may use methods provided by TestComplete (like you tried);
-- If the found object appeared to be native DOM one, then you should use native DOM functions like selectSingleNode(), selectNodes(), etc. and continue to work with the found child objects as with native DOM objects.
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms757828%28v%3dvs.85%29
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms764730(v=vs.85)
https://stackoverflow.com/questions/16016521/how-do-i-select-child-elements-of-any-depth-using-xpath
Related Content
- 5 years agoaa1
- 4 years agouserdanfoss
Recent Discussions
- 2 days agovladd1