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.

Clicking on a link in the webtable

vazidvazid Members
edited November -1 in Sahi - Open Source
The following peice of code works fine when i copy to evaluate expression box and test it. But when i have the same code in my scripts its not working. Sahi just stops there. Can any one have any idea why this behaviour is so??

Basically i'm trying to click a link in the webtable whose value i dont know. I just have to click on the first link appearing in the table.

var table = document.getElementById("srchValTbl");
var tr = table.getElementsByTagName("tr");
for (var $i = 0; $i < $tr.length; i++) {
var $td=$tr.getElementsByTagName("td");
var $checkbox=$td[1].getElementsByTagName("a")[0];
_click(_link($checkbox.innerHTML));
}

I tried this code as well

var $Edittable,Edittr,Edittd,Editcheckbox;

_set($Edittable, top.document.getElementById("checkBoxGrp000"));
_set($Edittr, $Edittable.getElementsByTagName("tr"));
_set($Edittd, $Edittr[0].getElementsByTagName("td"));
_set($Editcheckbox, $Edittd[0].getElementsByTagName("a")[0]);
_click(_link($Editcheckbox.innerHTML));
_wait(3000);

Comments

  • Here's a bug:

    for (var $i = 0; $i < $tr.length; i++) {

    should be:

    for (var $i = 0; $i < $tr.length; $i++) {
  • Hey thank you for identifying.
    But sahi stops at this step <<var table = document.getElementById("srchValTbl"); >> and it will not continue further.

    Im using FF3.0 and sahi version sahi_20080627.
    When the above step is encountered then an alert is displayed by browser for stopping of script or to continue.

    Appreciate any help on this.

    Rgds,
    Vazid
  • Does the alert say something like the script is busy..do you want to continue or stop the script?
  • adminadmin Administrators
    Use this:

    <browser>
    function getFirstLink(){
    var table = document.getElementById("srchValTbl");
    var tr = table.getElementsByTagName("tr");
    for (var i = 0; i < tr.length; i++) {
    var td = tr.getElementsByTagName("td");
    var checkbox = td[1].getElementsByTagName("a")[0];
    return checkbox.innerHTML;
    }
    }
    </browser>

    _click(_link(getFirstLink()));
Sign In or Register to comment.