18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Number of columns in a table

SelviSelvi Members
edited November -1 in Sahi - Open Source
Hi all,


I need code to find number of columns in a table..

Regards,
Selvi.D

Comments

  • narayannarayan Administrators
    Try

    var $columnCount;
    _set($columnCount, _table("tableId").rows[0].cells.length);
    _assertEqual(5, $columnCount);

    or

    _assertEqual(5, _table("tableId").rows[0].cells.length);
  • hi narayan,
    i tried ur both codes. But sahi wont accept it. Error comes like,
    _assertEqual(7, _table("ctl00_cphClientBody_grvDelStatusRpt").rows[0].cells.length); TypeError: '_sahi._table(...).rows' is null or not an object No trace available Click for browser script at PendingRequests (scripts/gmail.sah:15) [10735 ms]

    pls fix this issue.
  • Hi Arunbala,

    Both scripts specified by Narayan works fine for me. Please ensure that the table is not null.

    Can you post the script and error displayed on the Sahi Console.

    Regards,
    Theeran.
  • i already mentioned above my script and the error msg. My table is a dynamic one. The row count will changes. But the column remaining same. I dont know how i got fail. Am sure that the table is not null.
    Do u need details. I will post it.

    Thnx
  • Hi Arunbala,

    "'_sahi._table(...).rows' is null " error will be displayed only when the table is null, that is there is no row in the table.

    Since you have mentioned that the table is dynamic, It seems like the id for the table might be wrong. Please try to use the index of the table like table(0). Just hover the table, the sahi controller will identify the table with it index in Alternatives dropdownbox.

    You may also use _near, _in, _under APIs to identify the table more specifically.

    If you are still not successful, please reply with appropriate details,

    Regards,
    Theeran.
  • Thnk u so much Theeran. Its working fine. The problem is with table identification.
This discussion has been closed.