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.

Web Table

arunbalaarunbala Members
edited November -1 in Sahi - Open Source
Hi,
I just want to search in webtable. If my conditon is satisfies then it will click that link.
There are several cols and rows in my table. In 2nd column i have to make a search and click that link if it finds.

I dont know how to work with tables.
Pls help me

thnx

Comments

  • globalwormingglobalworming Moderators
    edited February 2012
    Hi arunbala

    it's legit that you post your question here, but I am wondering if you even try to solve your problems yourself. There is a documentation on each Api, there are so many posts in this forum. When I search for "table" I find a post where Sumitra provides some code to get the contents of a table.. maybe that provides some insight http://sahi.co.in/forums/viewtopic.php?pid=12178#p12178
    here is another post of narayan explaining relational Apis in the context of tables http://sahi.co.in/forums/viewtopic.php?pid=11796#p11796
    here a post of nagar where he identifies cells by _table().row[].cell[] http://sahi.co.in/forums/viewtopic.php?pid=10940#p10940
    and so on ... http://sahi.co.in/forums/viewtopic.php?id=3046

    then there is the documentation http://sahi.co.in/w/browser-accessor-apis look for "Accessors of Table related elements"

    You could also use the Sahi Controller, press Control and hover over the table. Pro tip: when you have an accessor selected, like for example _cell("") click in the accessor input field and append a "." so it looks like "_cell("")." this will open a contant assist dropdown where you have access to the objects attributes and functions. You could access a _table() , write the "." and see what happens. Scroll through the list and select "rows". Your accessor now looks like this "_table("").rows" and your value field contains something like [Html row collection]. This is obviously or not an array... select "_table("").rows[1]." and see what happens. Then read the Documentation again about the Use of Positional relations. Thats more than enough to figure it out youself.

    Maybe you presented a really serious problem, a use case nobody ever thought about, then please provide more information. I will gladly assist you to solve that problem.

    Regards
    Wormi
  • Hi arunbala,

    Try with the following script,
    var $table=_table("tableId");
    for(var $i=0;$i<$table.rows.length;$i++){
       if(_exists(_link("linkId",_in(_cell($table, rowId, 2)))))
       _click(_link("linkId",_in(_cell($table,rowId, 2))));
    }
    
    

    to check if _link("linkId") exists in the 2nd column of _row(rowId) in _table("tableId"). If such link exists, then performs click operation on that particular link.

    Hope, this might help you.

    Regards,
    Theeran.
  • Hi deeran,
    Thank u so much. I have tried ur scripts. But it throws some error. So i just modified ur script, but i didnt get.
    My script:

    _alert($Fdel);
    var $table=_table("myTable[2]");
    for(var $i=0;$i<$table.rows.length;$i++){
    if (_exists(_link($Fdel, _in(_cell($table, $i, 2)))))
    _click(_link($Fdel, _in(_cell($table,$i, 2))));
    }

    Error Msg:
    undefined: Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format

    Thnx
  • jasonbjasonb Members
    edited March 2013
    Hi globalworming,

    Those links you posted are no longer available, do you have any idea if they still exist or not?

    I'm trying to figure out how to find the row number where a particular text value is (it's a dynamically created table, so if something is deleted/added the row num will change.) Then I'd like to get the text from a column in that row so I can do an assert on it, and I think this thread is a good place to start helping me figure it out...

    So I need to slap something together which roughly follows the script example above but which only grabs the text and saves it to a variable for later use. Is it possible to get the rowId just by doing a text search?

    Thanks,
    | JB
Sign In or Register to comment.