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.

False FAILURE when using _getDB() and $rs

stevenlongstevenlong Members
edited November -1 in Sahi - Open Source
Hi all

I'm getting a false FAILURE when using _getDB(). The data is retrieved and used correctly, but the test is marked as a FAILURE with the error message "TypeError: '0.BUYERID' is null or not an object No trace available"

The relevant bits of code are below:
var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin://50.1.0.157:1521/B2BTEST", "username", "password");
var $rs = [];

_set($rs, db.select("select ponumber, buyerid from po_header where buyerid = 'HW' and archived_status is null and status = 4 and id in (select fk_purchase_order_id from po_line_item having count(fk_purchase_order_id) > 1 group by fk_purchase_order_id) and rownum <= 10"));

...

_setValue(_textbox("buyid"), $rs[0]["BUYERID"]);

...

_click(_link("Amend[" + (_row(_table(1), $rs[0]["PONUMBER"]).rowIndex-1) + "]"));
As stated, the data values for the buyerid and ponumber are both being retrieved and used in the script correctly, but the test is still being marked as a FAILURE.

Anyone else had this? Is there something else I should be doing to prevent the error?

Thanks.

Comments

  • I have found a workaround that sheds some more light on why this is happening.

    When declaring the array to hold the result set, $rs = [];, if I also declare that $rs[0] will be an array, I do not get the error message and the test passes correctly:
    var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin://50.1.0.157:1521/B2BTEST", "username", "password");
    var $rs = [];
    $rs[0] = [];
    
    _set($rs, db.select("select ponumber, buyerid from po_header where buyerid = 'HW' and archived_status is null and status = 4 and id in (select fk_purchase_order_id from po_line_item having count(fk_purchase_order_id) > 1 group by fk_purchase_order_id) and rownum = 1"));
    
    ...
    
    The problem with this workaround is that it would need to be done for every row returned by the select query. In this instance, I've changed my query to only return the first row (using rownum = 1 in the where clause).

    Obviously this approach would not work where a select query will return a result set of variable size.

    So, any better solutions would be very much appreciated for future use.

    Thanks.
  • Cheers for your message. I have just had the exact same problem, and I have used your suggestion and it worked a treat.

    Donna
Sign In or Register to comment.