How to get all rows from a table which are not visible

Ranorex Studio, Spy, Recorder, and Driver.
Posts: 30
Joined: Wed May 22, 2019 5:48 am

How to get all rows from a table which are not visible

Post by Priyanshu » Mon Nov 11, 2019 6:22 am

Hi Team,

I am facing problem to get all the table rows in a single view. Ranorex is capturing only the visible rows , I want to search the row within whole table but my data is only getting searched in visible rows. Attached snapshot. Please revert.

You do not have the required permissions to view the files attached to this post.

User avatar
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to get all rows from a table which are not visible

Post by odklizec » Mon Nov 11, 2019 9:02 am


At first, you are using an outdated and, I'm afraid, somewhat buggy version 9.0.0. I would strongly reccommned to update it with to something newer, ideally, most recent 9.2 (at very least 9.1.2).

On the other hand, updating Ranorex will most probably not fix your problem ;) What you are experiencing, is so called lazy-loading, which means only visible items are loaded in memory. This behavior increases the application speed and preserves memory. It's great for end-users, but it's very bad for you, as a test automation engineer :D

The only workaround is to scroll-up/down the table, using either mouse clicks on table scroll-bar or sending PageUp/Down shortcuts (my prefferred way). I would definitely start with Home button, to scroll the table to initial state, with visible rows 0, 1, 2,... Then you will have to create your own (internal) list of items, extracted from table. But before filling the list, you need to check, if the item you want to add to the list (I would do it on row-by-row basis), is not yet in your internal list. If not, add it, else skip it and continue with next row. Once all table rows are loaded in the list, you can either save it to file (prefferrably CSV), or simply search/validate what you want. In other words, there is no no simple way of using reference snapshot for comparison purposes. You need to write some serious code to achieve what you want. I'm afraid, I can't help you with this right now, but I'm sure you can manage it. Just start with simple things.

At first, find a way, how to scroll the table to 'top' position.
Then play with scrolling down.
Then learn, how to go through all table rows and cells and extract text from each cell. This could be done via code like this (edited code from this example):

Code: Select all

public void ReadTableContent(Ranorex.RepoItemInfo repoTableInfo) 
	Ranorex.Table tableAdapter = repoTableInfo.CreateAdapter<Ranorex.Table>(); 
    if (tableAdapter==null) 
        throw new Ranorex.ValidationException("Repo-item could not be accessed"); 
    // run through table-rows 
    for (int iRow = 0; iRow <= tableAdapter.Rows.Count - 1; iRow++) 
        int cellCountCur = tableAdapter.Rows[iRow].Cells.Count; 
        // run through cells in current row 
        for (int iCol = 0; iCol <= cellCountCur - 1; iCol++) 
            string aCurText = tableAdapter.Rows[iRow].Cells[iCol].As<Ranorex.Cell>().Text; 
            string validationMessage = string.Empty; 
            if (string.IsNullOrEmpty(aCurText)) 
                aCurText ="";
Then you need to store each cell to list, but before storing an item to list, you must check if given row is not in the list yet. And so on... ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration