Forum Discussion

kkrush's avatar
kkrush
Occasional Contributor
6 years ago
Solved

EvaluateXpath - using keyword test , can we use evaluateXpath.?

I am trying to use keyword test to perform evaluatexpath, but am not able to, as per the below example/code, can we do the same with keyword test? if yes, can you please provide me with the keyword steps and screenshots if possible.

 

Appreicate your reply.

 

Example as given in the testcomplete documentation

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/page/evaluatexpath-action-page-object.html



   // Obtain the Page object
   let url = "http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_button_type";
   Browsers.Item(btIExplorer).Run(url);
   let page = Sys.Browser("*").Page("*");

   // Call the function
   let arr = page.EvaluateXPath("//button[contains(@type, 'submit')]");

   // Check the result
   if (!strictEqual(arr, null))
   {
     // and click the first element that was found
    arr[0].Click(); // Note we refer to the array item
   }
   else 
   {
     // If nothing was found, post a message to the log
     Log.Error("Nothing was found.");
   }
}