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.

_assertEqual and _assertContainsText always pass

mjmckaymjmckay Members
edited August 2013 in Sahi - Open Source
I'm testing two textbox fields in a window for a value and I've noted that the _assertEqual or _assertContainsText functions never fail even when I set them up to fail.

What am I doing wrong?

I'm using Firefox and Sahi 4.4.

Here is the code:
_log("Product: " + fGetSearch("M_Product_ID"),"info");
_assertContainsText("Fertilizer#70_Fertilizer #70", fGetSearch("M_Product_ID"),"Error: tf_wip_product_info: product query for Fertilizer #70 did not find the right product");
_assertContainsText("dummy", fGetSearch("M_Product_ID"),"Error: tf_wip_product_info: product query for Fertilizer #70 did not find the right product");

The log output:
_log("Product: " + fGetSearch("M_Product_ID"),"info");
[auto] at 4-Aug-2013 9:06:26 AM
Product: Fertilizer#70_Fertilizer #70 at 4-Aug-2013 9:06:29 AM
_assertContainsText("Fertilizer#70_Fertilizer #70", fGetSearch("M_Product_ID"),"Error: tf_wip_product_info: product query for Fertilizer #70 did not find the right product");
[auto] at 4-Aug-2013 9:06:33 AM
_assertContainsText("dummy", fGetSearch("M_Product_ID"),"Error: tf_wip_product_info: product query for Fertilizer #70 did not find the right product");
[auto] at 4-Aug-2013 9:06:37 AM

The function fGetSearch() is:

//<browser>
/* ******************************************************************
*
* fSearch($FieldName)
*
* Returns the element for the specified field
*
*******************************************************************/
function fSearch($FieldName){
/* Double underscores required to prevent scheduling */
//__assertExists(__textbox(/^zk/, __in(__div("/^Field_" + $FieldName + "_/"))), "Error: fSearch() can't find field " + $FieldName);
return __textbox(/^zk/, __in(__div("/^Field_" + $FieldName + "_/")));
}
//</browser>

//<browser>
/* ******************************************************************
*
* fGetSearch($FieldName)
*
* Get the value/contents of a search field.
*
*******************************************************************/
function fGetSearch($FieldName) {
return __getText(fSearch($FieldName));
}
//</browser>

Answers

  • Hi mjmckay,
    I made a sample script to test out the functionalities of _assertEquals and _assertContainsText APIs and they are working properly i.e. they are failing when they need to.
    The problem should be somewhere in the way they have been implemented by you.
    Please have a look into at again. I am currently caught up with many things and hence unable to look into your code.

    Regards.
  • Thanks. I note the [auto] tag in the log, which means the tests are passing without actually being evaluated. I'm trying to lengthen the step times to see if that helps.

    Mike.
  • Hi Mike,
    Have you been able to resolve the problem you were facing?

    Regards.
Sign In or Register to comment.