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.

Obtaining Part of a Url

PanginoonPanginoon Members
edited November -1 in Sahi - Open Source
I have the following line in my for loop. Everything is work except I cannot for the life of me figure about to get part of a url. here is the line I have to get it:

record_id = _link(_getText(_cell(usertable, i, 1))).slice(35);

This of course is in a function wrapped in browser tags.

here is a sample of the full code:
<browser>
    function CopyRecords() {
           var usertable = _table(18);
           var records = new Array();
           for(var i = 0; i < usertable.rows.length; i++){
               records[i] = new Array();
          if(i = 0) {
              
          } else {
               //Record Name
               record_name = _getText(_cell(usertable, i, 1));
               //Nation ID
                record_id = _link(_getText(_cell(usertable, i, 1))).slice(35);
            
               records[i][0] = record_name;
               records[i][1] = record_id;
          }
           }
        return records;
    }
</browser>

_set($roster, CopyRecords());

for (var $i=0; $i<$roster.length; $i++){
        _debug(_cell($roster[$i][0]));
        _debug(_cell($roster[$i][1]));
}

Comments

  • The _link() function cannot use the link on the page as if we use pagination the next previous has additional links that throw that off.
  • narayannarayan Administrators
    Panginoon,

    _link(text) returns the DOM Element of the link. What you need is _link(text).href
    record_id = _link(_getText(_cell(usertable, i, 1))).href.slice(35);
    
Sign In or Register to comment.