0

我试图在一个函数中使用两次 Dialog 处理程序。第一次它执行得很好,但第二次它挂起系统并打开对话框并显示“确定”和“取消”按钮,但永远无法单击它。它也超时并出现错误“对话框在 60 秒内不可用”

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 

在我的代码中的 2 个地方使用它,第一次它执行良好,第二次在同一函数中它给出对话框不可用而它是可用的错误。

4

1 回答 1

2

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.

于 2009-03-25T11:09:09.017 回答