Question

In QTP, checkpoints can be used to define an expected state, which the checkpoint then checks.

That results in a checkpoint entry in the object repository (OR), which contains the identification properties of the test object to check/to query for the data, and: a timeout value.

For example, a bitmap checkpoint contains such a timeout value.

If you set it to 5 (using the bitmap checkpoint properties dialog), QTP attempts to wait for the actual image to match the expected image within 5 seconds.

If you set it to 0, QTP does not wait at all.

This is all documented well-defined behavior. OK.

Now -- what if my app became slower, and all my checkpoint timeouts have become too low so all of them now fail?

I will have to increase the timeout values manually in all checkpoints. Or, since I am "smart", I could export the object repositories to XML, and do a smart mass search-and-replace operation in those XML files with some clever tool.

This is ok if it is a one-time action. But what if this happens more than once in a year or so? What if you have not just one central OR, but lots and lot of action-repositories? The export alone would already be tedious.

Now -and this is the true situation that leads to this question- to have a unified :) timeout handling, I have one constant defined for a short and one for a long time interval (in seconds). All our tests' code uses one of these two constants if it needs to wait for something, poll for a state or do anything else that is timeout-related. We even set the default object recognition delay in QTP's web config programmatically to the short interval constant's value at library init to make sure that nobody uses a different value for "standard" timeouts during playback. This really helps to keep test results comparable.

This way, I can define maximum wait times (both of them, the one for quick operations like navigation and the one for long "big" jobs) centrally in my library code, simply by editing those two constant´s values. Cool.

Except for checkpoints. How can I force all checkpoints to use, say, the short interval constant´s value? I can't. So let's consider workarounds (which certain people would call solutions ;) :

  • First idea: parameterize the timeout. Scratch that, QTP does not support that.

  • Second idea: See above -- export all ORs, mass-search-and-replace, re-import. Scratch that, to replicate a central change this way is not exactly central configuration. And it is very error-prone if you have lots of per-action-ORs.

  • Third idea: Create a tool that uses QTPs object model (or automation object model) API to update the checkpoint values at test run-time. Mmmh. Extra code for .Check call. Mmmh.

  • Fourth idea: Considering that during checkpoint execution, every Checkpoint () reference fetched from the OR is passed to the particular test object´s Check method, one could create a global function that accepts a checkpoint, patches its timeout value, and calls the original Check method with the patched checkpoint. Then, the original Check method would use the timeout value it finds in the checkpoint. Great. But I would really have to register this custom Check method with every test object class I use. Or, to make it right, even in all test object classes QTP knows. Also, it seems to be far from trivial to access/update a checkpoint's timeout value during test runtime. But at least all those .Check .Checkpoint checkpoint calls could stay the way they are. Mmmmmh again.

Any better ideas? Has anybody tried this, or found an elegant solution to parameterizing timeout values in checkpoints?

Was it helpful?

Solution

I would probably go with your option #3, create some code that uses the AOM to get all objects of type Checkpoint from the associated object repositories. Then perform a SetTOProperty("step_timeout", yourValue) for each such object.

P.S. I found the name step_timeout by right-clicking on the checkpoint object in the script and choosing Object properties...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top