The web site has built in auto refresh every 4 seconds,so I lose my web control's object references.
- 9 years ago
Hi Bharadwaj,
I am afraid that you don't have too many options here if my guess about your tested application is correct.
I am taking that when an auto-refresh event occurs, script code on the web page destroys some parent object that you are trying to use in your test code and create it anew with the new data. Because this object is really released (and maybe even garbage collected), actions like refresh against it will not help and the only option is to get a new reference to the new created object and proceed.
Two possible workarounds that came to my head are:
a) Implement a OnLogError event handler in your test project and renew a reference to the not found object within it. This might work but you are anyway at risk that the number of events change after refresh and you will get a false negative test result;
b) Consider injection of your code into the tested web page. Ideally, this code must be executed within the function that updates the list of events so the auto-update event is not triggered until your code done. Maybe even the best approach is to ask developers to include some hidden controls on the web page and populate these controls with the data that you need. More about injection of custom script code into the web page: https://support.smartbear.com/articles/testcomplete/embedding-scripts-into-web-pages/ (from https://support.smartbear.com/articles/testcomplete/) and https://support.smartbear.com/viewarticle/69056/.
However, I think that the most reliable approach is to separate the auto-refresh functionality and the tested business functionality.
You may talk to developers and ask them how you can disable the auto-refresh. (You may use the approach from paragraph b) above and either set some variable on the page or call some page script function to disable the auto-refresh.) This will guarantee you that page structure will remain unchanged until your test code completes and you are guaranteed from false negatives. Auto-refresh can be enabled after the test is done.