Forum Discussion

Gaya's avatar
Gaya
Occasional Contributor
5 years ago
Solved

aqObject.CheckProperty- (checkpoint on Content text) Control does not go to else condition

Hi,

 

Is there anything wrong with below code? Control is not going to Else conditon even if the If condition is not true. It just evalutes If condition and throws an error.  

 

Note: Object properties for both are same only the "content text" differs.

 

if((aqObject.CheckProperty(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4, "contentText", cmpEqual, "Order accepted"))==true){
Log.Message("Order Accepted")
}
else{
if(aqObject.CheckProperty(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4, "contentText", cmpEqual, "A pending order already exists.")==true){
//Code goes here
}
}

  • I'd Expect so, yes.  

     

    A cleaner way of comparing though would probably be

    var doesCompare = aqstring.Compare(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText,"Order Placed",false);

    if(deosCompare==0)
    {
    ...
    }
    else
    {
    ...
    }

    since contentText is a property of a TC object.

     

    When you are doing the check, are you sure the contentText has changed e.g. what does Log(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText) tell you at each step of the process ?

     

    If it' not what you see on the screen, you may be able to Refresh mapping info

11 Replies

  • Two things to look at: The text has to match exact any differences e.g. a "." at the end of the text will return false.  Also, CaseSensitive is an optional parameter  By default the value is true if not specified.  If you add a CaseSensitive of false you may find the value to equate to true:

     

    aqObject.CheckProperty(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4, "contentText", cmpEqual, "Order accepted",false)

     

    aqObject.CheckProperty Method

    • Gaya's avatar
      Gaya
      Occasional Contributor

      Hi,

       

      Thanks for your reply. The text is exactly same how it is showing in object properties. I tried the Case Sensitive option as well still did not work.

      If condition evaluates to false then the Control should go to else right? but it is not going.

       

      • RUDOLF_BOTHMA's avatar
        RUDOLF_BOTHMA
        Community Hero

        I'd Expect so, yes.  

         

        A cleaner way of comparing though would probably be

        var doesCompare = aqstring.Compare(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText,"Order Placed",false);

        if(deosCompare==0)
        {
        ...
        }
        else
        {
        ...
        }

        since contentText is a property of a TC object.

         

        When you are doing the check, are you sure the contentText has changed e.g. what does Log(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText) tell you at each step of the process ?

         

        If it' not what you see on the screen, you may be able to Refresh mapping info