使用最终版 WatiN 时无法通过 Firefox 获得警报对话框
下面的代码在 IE7 上运行良好,但是当我切换到 Firefox(从 3.0 到 3.6)运行时,我无法获取该对话框。它在线引发错误:DiaglogHandler.WaitUntilExists(10)“对话框在 10 秒内不可用。”即使对话框在那里。我正在使用 WatiN 最终版本。
string url = "https://www.xxx.com"
Settings.AutoStartDialogWatcher = true;
Settings.AutoCloseDialogs = false;
//var browser = new IE();
var browser = new FireFox();
browser.GoTo(url);
Image theButton = browser.Image(Find.By("id", "button"));
AlertDialogHandler DiaglogHandler = new AlertDialogHandler();
DialogWatcher theDialogWatcher = new DialogWatcher(new WatiN.Core.Native.Windows.Window(browser.hWnd));
theDialogWatcher.Add(DiaglogHandler);
theDialogWatcher.CloseUnhandledDialogs = false;
theButton.ClickNoWait();
DiaglogHandler.WaitUntilExists(10);
Console.WriteLine(DiaglogHandler.Message);
Console.WriteLine("Done");
Console.ReadLine();
The code below works well with IE7, but when I switch to run with Firefox (from 3.0 to 3.6) I could not get the the Dialog. It raise error on line: DiaglogHandler.WaitUntilExists(10) "Dialog not available within 10 seconds." even though the dialog is there. I'm using the final WatiN release.
string url = "https://www.xxx.com"
Settings.AutoStartDialogWatcher = true;
Settings.AutoCloseDialogs = false;
//var browser = new IE();
var browser = new FireFox();
browser.GoTo(url);
Image theButton = browser.Image(Find.By("id", "button"));
AlertDialogHandler DiaglogHandler = new AlertDialogHandler();
DialogWatcher theDialogWatcher = new DialogWatcher(new WatiN.Core.Native.Windows.Window(browser.hWnd));
theDialogWatcher.Add(DiaglogHandler);
theDialogWatcher.CloseUnhandledDialogs = false;
theButton.ClickNoWait();
DiaglogHandler.WaitUntilExists(10);
Console.WriteLine(DiaglogHandler.Message);
Console.WriteLine("Done");
Console.ReadLine();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Afaik WatiN 还不能很好地处理 Dialogs,尽管它即将出现。
可以绕过它们,例如将 Enter 传递给浏览器或其他 JavaScript 交互。
我在 FireFox 中需要身份验证的对话框方面遇到了类似的问题
Afaik WatiN does not deal well with Dialogs yet, though it is on the horizon.
It is possible to get around them, say passing an Enter to the browser or other javascript interaction.
I've had similar issues with Authentication Required Dialogs in FireFox