Micro Focus QTP (UFT) Forums
Inconsistent click on an object - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Inconsistent click on an object (/Thread-Inconsistent-click-on-an-object)



Inconsistent click on an object - sidman - 06-09-2008

I have an object on a Crystal Report window that the click event does not work consistently. The object, which is the Print button/icon, receives focus, but the click event does not happen every time. The recorded line of code is as follows:

Code:
SwfWindow("Report").SwfObject("SwfObject").Click

I've tried the click event with coordinates and without and I've also tried mapping the object as a virtual object, but nothing seems to work. Any ideas on how to force the click event will be appreciated. Thanks!

(I'm using QTP 9.2 with Crystal Report 11 and a Windows .Net application.)


RE: Inconsistent click on an object - niranjan - 06-10-2008

Did u check the Object properties when the click event didnt work??


RE: Inconsistent click on an object - sidman - 06-10-2008

Yes, I did. It shows only the two objects that are indicated in the code example I've provided in my original post: SwfWindow: Report > SwfObject:SwfObject, which is the same as what displays if the Print button/icon is spied on using the .Net Windows Form Spy.

The normal Object Spy reveals a more detailed hierarchy: SwfWindow: Report > SwfObject: ReportUserControl > SwfObject:CrystalReportViewer > SwfObject: ToolBar > SwfObject: SwfObject. I tried adding the additional objects via the Define New Test Object option in the Object Repository, but that didn't help either.

The only thing that has seemed to help is to click on another button/icon on the Crystal Report and then click on the Print button/icon, but QTP is still not consistently clicking both buttons/icons.

It might also be a timing issue as I added a Wait before clicking the buttons/icons to give the report time to load and it has helped somewhat, but the button/icon click events are still not occurring consistently. Thank you!


RE: Inconsistent click on an object - niranjan - 06-10-2008

Hmmmm....
Instead of just wait statement, use the following...
Do
Wait 1
Loop Until (your object).Exist(1) ..... or (focus is true, somethng like that)