Ask a Question

How can I assert if a value is equal to another

clausbraatz
New Contributor

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?
Claus
39 REPLIES 39
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?



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+ "'");

  }



}

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?

Regards

Partha Mandayam
Software Consultant
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...


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

I need to do everything in TestComplete itself.

How would I access tooltip text in TestComplete?

How to log a message that the test passed to an external log file?

Regards

Partha Mandayam
Software Consultant
tristaanogre
Esteemed Contributor


@mcp111 wrote:

I need to do everything in TestComplete itself.

How would I access tooltip text in TestComplete?

How to log a message that the test passed to an external log file?


And my answer all involves TestComplete. Script units are part of TestComplete. so, if you want to write that code, you need to write script code in a script unit and then use "Run Script Routine" operation in your keyword test to execute. Object Spy is part of TestComplete. Property checkpoints are part of TestComplete.

 

So... I'm not sure what you're looking for.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

ok

When I googled Object Spy it showed QTP Object Spy so that's why I was confused.

When I looked in more detail I found that there was also a Testcomplete object spy.

I think I got what I need.

Thanks

Regards

Partha Mandayam
Software Consultant
tristaanogre
Esteemed Contributor

Rather than a simple google search, start with 

https://support.smartbear.com/testcomplete/docs/

 

That's ALL the TestComplete documentation in one place.  It's searchable... and it mirrors the Help that's built into the TestComplete tool... it also has built in tutorials, code examples, etc.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

When I do a property checkpoint on the exclamation mark, I don't see any tooltip property. So how to compare the tooltip text?

And if the text is correct then how to log that the text has passed?

Regards

Partha Mandayam
Software Consultant
cancel
Showing results for 
Search instead for 
Did you mean: