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.

how to get a count of links which have no linkids

edited November -1 in Sahi - Open Source
hi guys,

I have a number of links with a same name (View Details) which i need to click one by one.
the thing is the links have no ids this is the html code

<tr>
<TD class=smtRow>Aug 11</TD>
<TD class=smtRow>Yes</TD>
<TD class=smtRow><A href="ParticipantEligibilityDetails.aspx?UserDetails=JqH6AtSQRq6sz1in5WTU84j32i9%2buzZeEe%2bp7neLAfHAH9Rylyn90hJ%2fehJTvPs95e9kJVmM93R5WLj5ojHvrQ%3d%3d&benTypesName=Medical&UserName=CjY9zqLyRsStb4ZdXhg1PrNa2Jg6nrY1GdM4zAxrlCc%3d&LoggedInUser=True&BenefitType=M&CoverageMonth=Aug+11">View Details</A></TD>
<TD class=smtRow>NORTHWEST ADMINISTRATORS, INC.</TD>


i used the below code


var $v1;
_setValue($v1,"35");
for (var $vmore=0; $vmore<=$v1; $vmore++)
{
viewmore();
_click(_link("View Details[$vmore]"));
_click(_link("Forms and Documents", _in(_table("formBox"))));
_click(_link("Eligibility Status"));
_setSelected(_select("ddlSelectUser"), $y);
viewmore();
_click(_link("View Details[$vmore]"));
_click(_link("Click here to go back to Eligibility Status"));
}
_click(_link("Participant Home"));
}
_click(_link("Participant Home"));
}

but not able to run i am getting the below error

setValue(null,35);
Error: The first parameter passed to _setValue was not found on the browser
at Eligibility (scripts/Claimsfunction.sah:63) at Oct 12, 2011 4:24:09 PM

Comments

  • Hi Prasanth,

    hope the below script will be useful for u, try the below code


    ******************************************************************************

    //var $els = _collect("_link", "/specificpanelname/"); // this script is used to click the links under a specific panel(like div/ table/ etc...) in current page
    var $els = _collect("_link", "/./"); // this script is used to click all the links in current page
    _debug("Total No. of Links: "+ $els.length);
    for( var $i=0; $i<$els.length; $i++) {

    // v can use any 1 of the bleow scripts as per our necessity

    _click(_link($els[$i].text)); // 1st try with ".text" option because ur code doesn't contain id
    //_click(_link($els[$i].id));
    //_click(_link($els[$i].name));
    }


    ******************************************************************************

    do let me know if still facing any issue
  • Hi Prasanth,

    I think the problem is in this step
    _setValue($v1,"35");
    

    Please use,
    $v1 = 35;
    

    Alternately, you can use the _collect API to get all "View Details" links
    var $link;
    var $listItems = _collect("_link", "View Details");
    for(var $i=0; $i<$listItems.length; $i++) {
         $link = $listItems[$i];
         _click($link);
    }
    

    Regards,
    _dkulkarni
  • Thanks a Lot _dkulkarni its working fine....
This discussion has been closed.