I'm testing a Win98 application and one of the error messages doesn't have a caption. When I record the window declarations, it gives:
[-] window DialogBox MessageBox1
[ ] tag "$MessageBox"
[-] PushButton OK
[ ] tag "OK"
[-] CustomWin Icon1
[ ] msw tag "[Icon]#1"
[-] StaticText ExceptionEAccessViolationIn
[ ] tag "Exception EAccessViolation in module MSVBVM60.DLL at 000BE51B.?Access violation at address 660BE51B in module 'MSVBVM60.DLL'. *"
How do I change the tag for this message box so it identifies it by the contents of the StaticText for the Exception error message? Using a tag of "#1" for the index doesn't help because I'm using an IF statement to determine if the error exists and it sees the previous window as #1.
I've tried using a tag of:
[ ] tag "$MessageBox / [StaticText] Exception EAccessViolation in module*/.."
I must be doing it wrong because that doesn't work either.
I've had a similar situation, several message dialogs have the same tag information and you need to be able to uniquely identify them. The workaround that I'm using is I'll check to see if the static text exists.
i.e. if MessageBox1.StaticText3.Exists()
This way, if a message box exists, that branch of code will only be executed if the static text is equl to StaticText3.
I'm very intersted to see if someone knows how to accomplish exactly what you've asked for. Very good question.
The answer might be in precisely what you mean by "doesn't work". When you use a tag that includes a reference to a control on the window none of the "record" functions will appear to acknowledge the window dec but all should be fine at script/testcase runtime. There have been a few other recent threads regarding this format for the tag so you might want to go find them for more info.
My personal experience with this tag format is that I have never been able to get it to work in any of my AUTs but I have gotten it to work just fine using the GMO app that Segue uses for demos and training.
I use the same method as described above. I have a lot of windows with the same caption and I use it for tabbed dialog boxes. If I want to see if a specific one exists I check for a unique object on the screen. I have also written my own Exists methods inside the window declaration. For example:
You can use the unique child StaticText object in the tag:
The last /.. at the end is mandadory, it tells the Agent to evaluate the parent / child relationship (e.g. a dialog box with any caption, with StaticText Access violation*)