views:

234

answers:

1

I am trying to use Dialog handler twice in a function. For first time it executes well but on second time it hangs the system with dialog box open and showing Ok and Cancel butoon but never able to click it. Also it times out with an error "Dialog not available within 60 seconds"

Dim cdhPopup As ConfirmDialogHandler 
cdhPopup = New ConfirmDialogHandler() 
If (ie.Button(Find.ById("btnDelete")).Exists) Then
    'Cancel the booking '
    ie.AddDialogHandler(cdhPopup) 
    ie.Button(Find.ById("btnDelete")).ClickNoWait() 
    cdhPopup.WaitUntilExists() 
    cdhPopup.OKButton.Click() 
    ie.WaitForComplete() 'Wait for page to finish loading '
Else 
    Assert.Fail("Could not found the Cancel Button") 
End If

Using this at 2 places in my code, First time it executes fine and second time within same function it gives dialog not available whereas it is available error.

+1  A: 

My best guess is that in the second pass you are again calling ie.AddDialogHandler(cdhPopup), thereby registering it a second time, which is somehow crashing the program when the handlers are invoked (cross thread access to internal variables maybe?)

You should perform a check if the handler is registered, and only register it if it isn't.

Treb
Thank you so much. yes you're right. It is crashing on registration
sam