I recorded the basic steps I need my automation script to perform on our Java app. The step of interest is that a dialog pops up to confirm whether to continue, which resulted in the line JavaWindow("Stream Management").JavaDialog("Delete Alpha1").JavaButton("Yes").Click . The problem is that the "Alpha1" part of the dialog title is variable (I can extract the actual value in script), so I don't think I can use the OR for each possible call.
My query is, to use DP, do I need to do a ".Create" on 2 objects, one for the dialog and one for the button? And how are they then referenced? Would it be something like JavaWindow("Stream Management").JavaDialog(Object1).JavaButton(Object 2).Click, or JavaWindow("Stream Management").Object1.Object2.Click, or something else?
I know I'll need to work out the specifics of what objects to create, but some confirmation that I'm at least heading the right direction would be good... Thanks!
[ QUOTE ]
The problem is that the "Alpha1" part of the dialog title is variable (I can extract the actual value in script), so I don't think I can use the OR for each possible call.
[/ QUOTE ]
The OR supports using regular expressions, so if the variable dialog title is your only reason to not use the OR, it's most likely not a valid reason.
1. Open the OR.
2. Add the dialog to the OR (unless it is already there).
3. Change the name of the dialog to something generic, like "Delete Confirmation" or something similar (this is not necessary; QTP doesn't care what you call it, but it might make your scripts more consistent).
4. Highlight the title property of the dialog box (in the OR under Description Properties), then click anywhere inside the Value column of the title property to make the little button appear that allows you to edit that value. The button caption looks like <#>
5. Click the Regular expression checkbox in the Value Configuration Options popup.
6. Edit the Constant value to be something like "Delete.*"
7. Click OK to close the Value Configuration Options popup.
8. In the OR toolbar, click the "Highlight in Application" button to make the dialog flash in the application - this verifies that your changes are valid. If it doesn't flash, then you did something wrong when you edited the value.
9. Close the OR.
Once this is done, your Delete popup dialog will work regardless of the variable name of the dialog.
I couldn't get the OR regular expression side of things working when I tried yesterday. However, I've just followed the very clear steps above, and got it working. I'm pretty sure my problem yesterday was due to not using the generic name (eg "Delete Confirmation") in the script when referencing the object.
Now this works, for my current project, sticking with the OR as you suggest rather than investigating DP is the best approach. Thanks a lot for the help.