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.

_under(_cell...) bug?

smitty1_2smitty1_2 Members
edited November -1 in Sahi - Open Source
OS: Win7, 64bit
Browser: Firefox 3.6.15
Sahi (Build: 2011-03-14)


Hi,

I have two different http responses. One is a html site with a table. One is only a JSON String with the same information as in the table. I compare the two responses with _assertEqual.
This works fine to a certain point where it seems that _getText(_cell($i, _under(_cell("Vessel Depart")))) doesn't work properly. I paste the code in here so that you can run it yourself. The command works fine for the first row. But then it seems like it's skipping the row but coming out one column before the requested one. Then it goes one to the right and the same thing with the skip again.
You will have to take away the brackets in the first line of the code at (http).
Thanks for your effort.
var $url = "(http)://apll.idc.freightgate.com/ws1_8080/apl/iSail3?service_code=GUR&origin_code=THLCH&destination_code=92647&from_date=16-Mar-2011&to_date=27-Apr-2011";

_navigateTo($url);


// rowCount of html table

<browser>
    function getRowCount() {
        return _table(5).rows.length;
    }
</browser>

var $rowCount=0;
_set($rowCount, getRowCount());


// HTML data arrays

var $vesselVoyage = new Array(); 
var $vesselService = new Array(); 
var $cutoff = new Array(); 
var $loadPort = new Array();
var $vesselDepart = new Array();
var $vesselArrive = new Array();
var $dischargePort = new Array();
var $vslDepToVslArr = new Array();
var $serviceType = new Array();
var $guaranteedDelivery = new Array();
var $vslDepToDelivery = new Array();
var $deliveryDate = new Array();


// put HTML data in arrays
// rowCount-1 because rowCount includes the column description

for (var $i=0; $i < $rowCount-1; $i++) {
    $vesselVoyage[$i] = _getText(_cell($i, _under(_cell("Vessel Voyage"))));
    $cutoff[$i] = _getText(_cell($i, _under(_cell("CFS Cut-Off"))));
    $loadPort[$i] = _getText(_cell($i, _under(_cell("Load Port"))));
    $vesselDepart[$i] = _getText(_cell($i, _under(_cell("Vessel Depart")))); // thats the crucial line
    $vesselArrive[$i] = _getText(_cell($i, _under(_cell("Vessel Arrive"))));
    $dischargePort[$i] = _getText(_cell($i, _under(_cell("Discharge Port"))));
    $deliveryDate[$i] = _getText(_cell($i, _under(_cell("Delivery Date"))));        
    $vslDepToVslArr[$i] = _getText(_cell($i, _under(_cell("Vess Dep to Vess Arrive"))));
    $vslDepToDelivery[$i] = _getText(_cell($i, _under(_cell("Vess Dep to Delivery"))));
}

// the json that will come from the http request when the implementation is done
var $json = [{"vesselVoyage":"MOL PROSPERITY V043","loadPort":"Bangkok (Laem Chabang)","vesselArrive":"11-Apr-2011","dischargePort":"Los Angeles, CA","deliveryDate":"14-Apr-2011","vesselDepart":"21-Mar-2011","vslDepToDelivery":"24","vslDepToVslArr":"21","cutoff":"Wed 12:00 16-Mar-2011"},{"vesselVoyage":"MOL PRESENCE V027","loadPort":"Bangkok (Laem Chabang)","vesselArrive":"18-Apr-2011","dischargePort":"Los Angeles, CA","deliveryDate":"21-Apr-2011","vesselDepart":"28-Mar-2011","vslDepToDelivery":"24","vslDepToVslArr":"21","cutoff":"Wed 12:00 23-Mar-2011"},{"vesselVoyage":"MOL PRESTIGE V022","loadPort":"Bangkok (Laem Chabang)","vesselArrive":"25-Apr-2011","dischargePort":"Los Angeles, CA","deliveryDate":"28-Apr-2011","vesselDepart":"04-Apr-2011","vslDepToDelivery":"24","vslDepToVslArr":"21","cutoff":"Wed 12:00 30-Mar-2011"},{"vesselVoyage":"MOL PROMISE V062","loadPort":"Bangkok (Laem Chabang)","vesselArrive":"02-May-2011","dischargePort":"Los Angeles, CA","deliveryDate":"05-May-2011","vesselDepart":"11-Apr-2011","vslDepToDelivery":"24","vslDepToVslArr":"21","cutoff":"Wed 12:00 06-Apr-2011"},{"vesselVoyage":"MOL PARADISE V044","loadPort":"Bangkok (Laem Chabang)","vesselArrive":"09-May-2011","dischargePort":"Los Angeles, CA","deliveryDate":"12-May-2011","vesselDepart":"18-Apr-2011","vslDepToDelivery":"24","vslDepToVslArr":"21","cutoff":"Wed 12:00 13-Apr-2011"},{"vesselVoyage":"MOL PROGESS V056","loadPort":"Bangkok (Laem Chabang)","vesselArrive":"16-May-2011","dischargePort":"Los Angeles, CA","deliveryDate":"19-May-2011","vesselDepart":"25-Apr-2011","vslDepToDelivery":"24","vslDepToVslArr":"21","cutoff":"Wed 12:00 20-Apr-2011"}];


// asserts

for (var $i=0; $i < $rowCount-1; $i++) {
    _assertEqual($json[$i].vesselVoyage, $vesselVoyage[$i]);
    _assertEqual($json[$i].cutoff, $cutoff[$i]);
    _assertEqual($json[$i].loadPort, $loadPort[$i]);
    _assertEqual($json[$i].vesselDepart, $vesselDepart[$i]);
    _assertEqual($json[$i].vesselArrive, $vesselArrive[$i]);
    _assertEqual($json[$i].dischargePort, $dischargePort[$i]);
    _assertEqual($json[$i].deliveryDate, $deliveryDate[$i]);
    _assertEqual($json[$i].vslDepToVslArr, $vslDepToVslArr[$i]);
    _assertEqual($json[$i].vslDepToDelivery, $vslDepToDelivery[$i]);
}

Comments

  • narayannarayan Administrators
    Hi smitty1_2,

    We could reproduce the behaviour. While we look into it to see what the cause is, could you please use this?
    // $vesselDepart[$i] = _getText(_cell($i, _under(_cell("Vessel Depart")))); // thats the crucial line
    $vesselDepart[$i] = _getText(_cell(_parentTable(_cell("Vessel Depart")), $i+1, "Vessel Depart")); 
    

    We are using the
    _cell(table, rowIdentifier, colIdentifier) syntax

    _parentTable(_cell("Vessel Depart")) is used because the table does not have an id. We could also have used _table(5) in this case, but it becomes dependent on table index then.

    Regards,
    Narayan
  • smitty1_2smitty1_2 Members
    edited March 2011
    Thanks!
    I knew the _cell(table, ...) syntax but I didn't come across the _parentTable thing.

    Kind regards

    Edit: Just to make sure: It works with:
    $vesselVoyage[$i] = _getText(_cell((_parentTable(_cell("Vessel Voyage"))), $i+1, "Vessel Voyage"));
This discussion has been closed.