Forum Discussion

fayizkc's avatar
Occasional Contributor
6 years ago

FindChildByXPath is not working on the object created by EvaluateXPath method

I created array of object by EvaluateXPath. When I loop to that object and use FindChildByXPath, not supporting this method error is appearing.

Here in the code.



var obj1 = MyWebpageObject.EvaluateXPath("//ul[@id='UserList']/li");
var arrObj = obj1.toArray();
for (var i in arrObj){
var objDate = arrObj[i].FindChildByXPath("//span[@id,'txt-date']")


When it is executing arrObj[i].FindChildByXPath, throwing an error as "Object doen't support this propertyt or method"




3 Replies

  • AlexKaras's avatar
    Champion Level 3



    This behaviour is explained in the 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.



    • fayizkc's avatar
      Occasional Contributor

      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 



      	<li class = "some Class">
      		<span class = "some calss2">


      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