等待捕获弹出窗口并单击“是”
我使用 watin 登录网站并检索信息。如果同一帐户在其他地方已经存在另一个登录,网站会弹出一个窗口并显示“关闭其他会话?”并且有两个按钮“是”和“否”。我需要捕获它并单击“是”。
我不知道弹出窗口是什么类型,我尝试了AlertDialogHandler和ConfirmDialogHandler,但似乎不起作用,有人可以帮忙吗?下面是代码片段。谢谢!
BrowserIe.Ie.Image(Find.ByName("login")).ClickNoWait();
AlertDialogHandler d= new AlertDialogHandler();
if(d.Exists())
{
log.Debug("got alert dialog when logging in...");
d.OKButton.Click();
}
ConfirmDialogHandler confirm = new ConfirmDialogHandler();
if(confirm.Exists())
{
{
log.Debug("got confirm dialog when logging in...");
confirm.OKButton.Click();
}
}
I use watin to log into a website and retrieve information. If there is another login already exist for the same account in somewhere else, the website popup a window and say "close other sessions?" and there are two buttons "Yes" and "No". I need to capture this and click "Yes".
I don't know what type of the popup is, I tried AlertDialogHandler and ConfirmDialogHandler, but seems not working, could anyone help?? below is the code sniplet. Thanks!
BrowserIe.Ie.Image(Find.ByName("login")).ClickNoWait();
AlertDialogHandler d= new AlertDialogHandler();
if(d.Exists())
{
log.Debug("got alert dialog when logging in...");
d.OKButton.Click();
}
ConfirmDialogHandler confirm = new ConfirmDialogHandler();
if(confirm.Exists())
{
{
log.Debug("got confirm dialog when logging in...");
confirm.OKButton.Click();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可行:
根据消息的速度,您甚至可能不需要 Wait 方法。
另一种给这只猫剥皮的方法是重写 JavaScript 确认函数,返回 true:
This should work:
Depending on the speed of the message, you may not even need the Wait method.
Another way to skin this same cat is to override the JavaScript confirm function, returning true:
我见过的例子都更像这样:-
The examples I've seen have all looked more like this: -