| || |
Declaring a common window
I am testing a Web App using 126.96.36.199 SilkTest
I have a bunch of MainWin's in my application that has a common structure. They have a HTMLTable and the HTMLTable has a HTMLCol. And this Col holds the various child windows like textfield, checkboxes plus a common set of 6 Buttons
I want to declare a common MainWin that has the base structure with the Table, Col and the 6 Common Buttons and then I want to derive all the windows from this . Can anyone suggest me some way of doing this ??
Re: Declaring a common window
This is possible I believe; I have done similar things with some of the many similar ChildWins in our aut.
You will need a winclass declaration, inheriting from MainWin, and have your application windows inherit from your custom winclass. In the winclass, you can declare all the controls which are common to your various different windows; these will be inherited by your various windows that you descend from the winclass, and will be treated just as if they were declared in each individual window declaration separately.
One problem you will need to work round is that if you have the HTMLTable and the HTMLCol declared in your winclass (in order to hold the 6 common Buttons), but also declared in your individual window declarations (in order to hold the various different controls that other windows have), then you will need to give the one declared in your winclass a different name from the one declared in the window declaration. Otherwise your window will think it has two objects with the same name, and get very confused.
To be honest, I would be tempted not to bother with having these controls inherited from a winclass; it is easier just to let Record Window Declaration deal with them each time round. You will in any case need to declare the HTMLTable and HTMLCol again in each window declaration, for the controls (textfields, checkboxes) you mention which aren't common across all the windows.
I tend to find winclass declarations more useful for defining common methods which can then be inherited (because otherwise I really would be typing in the method for each similar window; there isn't much effort saved, or programming elegance gained, from having your controls inherited from a custom winclass.
The one exception to that general rule that I have discovered (and there may be others), was in the case of a particularly big window in our aut, where the controls present on this window varied so much (depending on various factors to do with the data this window was processing) that I couldn't use just one window declaration, but had to use several different declarations (for the one window), just to get the tags sorted out nicely. In that case, just to tidy things up a little, I had some of the common controls inherited from a winclass (though again, the main virtue of the winclass was to inherit methods from).
[This message has been edited by vincebowdren (edited 06-28-2001).]
Re: Declaring a common window
If I have a bunch of windows which contain most of the same information, I create a winclass declaration for them and put the common object at the winclass level. I then use this winclass for my window declaration. The unique items are place at the window declaration level. An example is my Add / Edit Company screens, 90% of the fields are redundant.
When I then want to reference the class I would:
If you don't use the DontInheritClassTag setting, the next time you record a BrowserChild it will be recorded with your winclass type. I believe you can use the same method for the MainWin class? Are you sure this is the correct class type you're interested in?