How can you override the Click method for HtmlLink objects to use the GetRect() method in SilkTest?
What you do is extend the HtmlLink object, and override the Click ( ) method by defining one of your own. The new Click () method does a GetRect () on the HtmlLink object, and then uses the return values to perform the click.
Firstly define a new class which extends the HtmlLink class. Inside this new class define your own Click () method to use GetRect (). By defining this method you effectively override the original Click () method for an HtmlLink object.
[-] winclass HtmlLink2: HtmlLink [-] Click () [ ] RECT rImage = this.GetRect () [ ] wMainWindow.Click(1,(rImage.xPos + rImage.xSize/2),(rImage.yPos + rImage.ySize/2))
Note: The Click performed will be from the top left corner of the object + half the length across + half the breadth down which will mean that the click will occur in the centre of the object.
Inside your declarations replace all instances of HtmlLink with HtmlLink2
[+] HtmlLink TestLink [+] multitag "Test Link" [ ] "#1" [ ] "$http:??www.test.com?"
[+] HtmlLink2 TestLink [+] multitag "Test Link" [ ] "#1" [ ] "$http:??www.test.com?"
Then to use this you simply go