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
// 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.");
}
}
Hi,
Thank you for the project.
Well, I was not able to access your tested site (no navigation error in the browser but the page was just empty), so I replaced it with https://www.potnoodle.com in both, Keyword test and NameMapping.
Also I changed type of the VarTemp test local variable from String to Object (as it is expected to store a reference to the found web element, but not a string).
After that I was able to execute keyword test with this line of code for the Run Code Snippet operation:
Aliases.browser.pageXXXURL.QuerySelector("a.login-to-load.ng-star-inserted");
(Obviously, the test reported that nothing was found but there was no exception.)
Unfortunately, test failed with the Type Mismatch error when I tried to use .QuerySelectorAll() and store search result to the VarTemp variable. I think this is because .QuerySelectorAll() returns an array and (even empty) array cannot be assigned to the keyword test local variable of either Object or any other built-in type.
I don't know if it is possible to assign an array that is obtained as the result of the last operation to the keyword test local variable as I am almost do not use keyword testing. Maybe those who use it will be able to provide you with some piece of advice.