tags:

views:

8

answers:

0

I'm autmating the UI of our web application using Watin. One of the page (X) has got an anchor tag which navigates to another page (Y). Page X pops up an confirm dialog on "OnBeforeUnload" event. So when someone manually clicks on the anchor tag, the confirm dialog pops up and when user clicks on the ok button the navigation continues. If the user clicks on cancel button, the navigation is cancelled.

When I try to automate this using Watin, when I call the Click method like below

this.browser.Link(Find.ByTitle("Id")).Click()

The confirm dialog pops up, closes (neither ok nor cancel is clicked) and watin throws a COM exception. Debugging through the watin code has led to IEElement.ClickOnElement method throwing this exception. This method has following code

public void ClickOnElement()
{
    AsDispHTMLBaseElement.click();
}

Here AsDispHTMLBaseElement is of type mshtml.HTMLAnchorElementClass.

My initial guess is that the mshtml's handling of click is interfering with the OnBeforeUnload event of page but I do not have any idea of how mshtml does the "click" to valiudate my guess.

Has anyone seen such a problem before? Or has anyone any idea of how mshtml performs the click of an anchor tag?