Forum Discussion

clausbraatz's avatar
clausbraatz
New Contributor
11 years ago

How can I assert if a value is equal to another

How can I assert that a value is equals to another?. What I am tryin to do is assert if a value is true, or maybe assert if a string is equals to another, but not using UI object properties. Is there any checkpoint or something like that to work with own variables?

39 Replies

  • sastowe's avatar
    sastowe
    Super Contributor
    Log.Checkpoint. So



    If sString1 = sString1 then

        Log.Checkpoint "The strings are equal","" ,,,Sys.Desktop.Picture()

    end if



    Is that what you meant?



    • mcp111's avatar
      mcp111
      Contributor

      Where to write this code?

       

      Also in my desktop application, the error message is displayed in a tooltip when I hover over an exclamation mark icon.

       

      I need to read that tooltip message and then log to an external file that the test has passed

       

      How to do this?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        You're asking a lot of information in a simple question, mcp111. :)  

         

        So... to start with, the code is written in a Script unit.  Read the following for writing script tests in TestComplete.

        https://support.smartbear.com/testcomplete/docs/scripting/overview.html

         

        As for the tooltip, I would use Object Spy to determine how the tool tip shows up.  Sometimes the tooltip is its own object...  sometimes it's a property of the object that has the tool tip assigned.  So, you will need to first need to determine where the tool tip is.  From that point, it's either code a HoverMouse action over the exclamation mark icon and do a property checkpoint on the tool tip object... OR, do a property checkpoint on the exclamation mark icon for the tool-tip property...

  • chicks's avatar
    chicks
    Regular Contributor
    This is javascript but I'm sure you can do the equivalent....





       CheckEquals( displayeRetailerId, expectedRetailerID, "retailerID" );



    function CheckEquals(aValue1, aValue2, aDescription) {

     

    // Log.Message ("one: "+aValue1 + " two: "+ aValue2);



     if (aValue1 != aValue2) {

        Log.Error(aDescription + " '" + aValue1 + "' does NOT match value '" + aValue2+"'");

        Log.Message("string 1 in additional info.", aValue1);

      }

      else {

        Log.Checkpoint(aDescription + " '" + aValue1 + " matches value '"+ aValue2+ "'");

      }



    }