【发布时间】:2025-12-10 23:50:02
【问题描述】:
我正在尝试自动化一个网站,在我的项目中单击“提交”按钮后,会出现一条带有确定按钮的警报消息。我想点击确定按钮。
我分别尝试了这两个代码,但这些代码不起作用
AlertDialogHandler AlertDialog = new AlertDialogHandler();
ie.AddDialogHandler(AlertDialog);
ie.Button(Find.ByValue("Submit")).ClickNoWait();
AlertDialog.WaitUntilExists();
AlertDialog.OKButton.Click();
ie.WaitForComplete();
ie.RemoveDialogHandler(AlertDialog);
var AlertDialogHandler = new AlertDialogHandler();
using (new UseDialogOnce(ie.DialogWatcher, AlertDialogHandler))
{
ie.Button(Find.ByValue("Submit")).ClickNoWait();
AlertDialogHandler.WaitUntilExists(50);
var message = AlertDialogHandler.Message;
AlertDialogHandler.OKButton.Click();
ie.WaitForComplete();
}
在使用这两个代码时,我得到了相同的异常“对话框在 30 秒内不可用”。
任何帮助将不胜感激。谢谢你:)
【问题讨论】: