Forum Discussion
rraghvani
Champion Level 3
Here's an example,
function Test1()
{
var page = Sys.Browser().Page("https://services.smartbear.com/samples/TestComplete15/smartstore");
var artlist = page.FindElement("//section//div[contains(@class, 'artlist')]");
var res = artlist.QuerySelectorAll("article");
if (!strictEqual(res, null)) {
Log.Message("Number of items found: " + res.length);
for (var i = 0; i < res.length; i++) {
Log.Message(res[i].contentText);
}
} else {
Log.Warning("The element was not found");
}
}
tvklovesu
2 years agoFrequent Contributor
Hi rraghvani, I used the same document to get the code snippet and changed according to my requirement. But any how thanks for looking in to this. Actually I was able to fix the issue my self that the testedPage object I am using the wrong parent element. There is one more level up parent which refers to the complete frame, and after referring that element then I was able to get the correct count.
The fix is
CSSSelector = "div[data-testid='canvasItem']"
TestedPage = NameMapping.Sys.browser.pageRavenCore.canvas_Window
Using this the TestedPage.QuerySelectorAll(CSSSelector) returned the correct count