Discussion

Pegasystems Inc.
US
Last activity: 15 Oct 2024 15:41 EDT
How to Wait for an HTML Tables Rows to Match
If you have interrogated an HTML table and need to process each row, you may notice that the table will match before all of the rows are matched. This is because when you enable UseKeys on a control (in this case the table row would have UseKeys enabled), its matching occurs outside of the normal thread of matching. This is at least partially due to the fact that rows can be added to a table at any time. You'd want to match new rows as they are added to the table and not have to go through matching or re-matching everything else on the page. If you do have a table that loads all of its data up front however, here is an easy way to wait for all the table rows to get created.
This automation will pause for 250 milliseconds and then get a count of the current number of rows. If this number is different than the last time it was checked, it will return to the loop and check again. If this count is the same as it was previously, then it is safe to assume no more rows are being added. Matching is generally a quick process, so 250 milliseconds is enough time for at least one row to match if the process is still going on.
You may use this technique whenever you wish to wait for a list of clones to be created. I have also altered it slightly in the past to add logic to only return if the number of rows changes at least once. This is helpful if you are adding a row to the table, but the processing of the website makes it take a few seconds before the row actually gets added.