FindAll Method Not Returning Anything

Originally posted by vladd1 on October 15, 2025

This is hopefully a straightforward solution for someone out there with far more experience than I. My application has rows inside a parent element. Each row is segmented so it also appears to have columns. I need to get all the “add user” buttons that are in a ‘column’ together in one array and loop through it.

Roughly

<div> <row 1> <stuff I dont need> <button I do need> <row 2> <stuff I dont need> <button I do need> <row 3> <stuff I dont need> <button I do need></div>

I believe the FindAll or FindAllChildren is the correct route but I am getting empty arrays returned. The buttons all have the same text “Add User” and are SPAN elements (not actually a button element). The buttons are all in the rows as I described and are contained in one parent DIV that wraps around all the rows. (Unfortunately not the column).

This is close to what I have without sharing exact code:

let column = page.FindElement("//div[contains(@class, 'random-css')]"); Log.Message(column.FindAllChildren("SPAN", "Add User", 300000))>> returns nullThank you

Originally posted by scot1967 on October 15, 2025

Hello vladd1,

FindElements returns an array of objects you can loop though.

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

… If you find my posts helpful drop me a like! :+1: Be sure to mark or post the solution to help others out and/or to credit the one who helped you. :smiling_face_with_sunglasses:

Originally posted by vladd1 on October 15, 2025

Hello Scot1967,

First off, thank you! I had not found that method before and it seems very useful. Second I tried implementing it into my code and while I did not get an error I also did not seem to get success. What I did get was an empty response row in my TC log, and when I created a loop around my column element I then got 14 empty responses in TC, when there are 21 rows. Could the issue be that I am logging my result in a message?

Updated from your suggestion:

 let column = page.FindElements("//span[.='Add User']");
  for(var i = 0; i < column.length; i++) {
      Log.Message(column[i])
  }

Originally posted by vladd1 on October 15, 2025

Scot1967 I rescind my earlier response, I think with enough tweaking and inspecting I can work with the solution you provided. Thank you so much! Solved

Originally posted by scot1967 on October 15, 2025

If you are not returning an empty array then you should see objects if you inspect the array by setting a break and a watch. The array will contain objects so you will need to refer to an object property to log anything.

Maybe like this? (Not sure what properties you have)

let column = page.FindElements("//span[.='Add User']");
for (var i = 0; i < column.length; i++) {
    Log.Message(column[i].Name);
}

Originally posted by scot1967 on October 15, 2025

Sounds like you have it… maybe .contentText) or .innerText would get you the name text?

Have a good one!