UFT 11.52: Execute a function automatically on each action call
Say I have a function in a common function library. Is it possible to automatically call this function from my tests each time they are being run, i.e. each time UFT opens and executes all the actions in a particular test?
The reason for why I wish to this is that I am currently working on integrating UFT with Compuware APM (Dynatrace) and wish to tag our tests using the test and action names, so that we can create dashboards in Dynatrace based on these names instead of URL's. When we have 100++ tests, it is kind of tedious to manually have to add a call the function for tagging the tests in all of our scripts. Thus, I am looking for a way to automate this task.
It would be nice if there existed something like a global "onActionCalled" method which could be overridden...
You could write a small FSO script that binds to your script folder, recursively traverses all the sub folders looking for folders named Action1, opens the Script.mts file in those folders and adds the call to the beginning/end of the script. I've done these kind of global changes in the past and never subsequently had any issues with the script.
That is a good idea. However, all our tests are stored in ALM - though I guess it should still be possible to write a script that checks them out/downloads them and modifies them according to your proposal. Additionally, folder names usually reflects the action name in a test, doesn't it (and we have few, if any at all, which are named "Action1")?
Put code in an associated function library, outside of a function.
The code will be executed when the QFL is loaded (when the action starts up)
... just another Tester ...
I have already tried this, and it does work to some extent. The problem arises when a test consists of many actions (either internal or calls to reusable external actions). With your suggestion the code will only be executed once, i.e. for the first action that is executed in a test - not any of the subsequent ones.
The parent folder reflects the test name, the controlling action folder is Action0 and the actual action folders are named Action1,2,3 etc.
Originally Posted by nils1k
Just was thinking about this, how about using GetObject to get an existing instance of qtp and get current action being executed using AOM in another script which would be running in parallel to QTP script.
During run-time every time current action changes how about triggering a function call? Let know what you think.