如何在 WatiN 中检测 Javascript 弹出通知?
我正在尝试解决一个似乎相当常见的场景。
我有一个网站接受通过两个不同文本字段的输入。如果输入格式错误或无效,我会收到 Javascript 弹出通知。
我不会总是收到一个,但我应该在发生(就像我之前所说的)数据格式错误或找不到搜索结果时收到。
我如何在 WatiN 中检测到这一点?
快速谷歌搜索产生的结果显示了如何点击它们,但我很好奇我是否可以检测到我何时得到一个?
如果有人想知道,我正在使用 WatiN 为我做一些屏幕抓取,而不是集成测试:)
提前致谢!
伊恩
I have a, what seems to be, rather common scenario I'm trying to work through.
I have a site that accepts input through two different text fields. If the input is malformed or invalid, I receive a Javascript pop-up notification.
I will not always receive one, but I should in the event of (like I said earlier) malformed data, or when a search result couldn't be found.
How can I detect this in WatiN?
A quick Google search produced results that show how to click through them, but I'm curious as to whether or not I can detect when I get one?
In case anyone is wondering, I'm using WatiN to do some screen scraping for me, rather than integration testing :)
Thanks in advance!
Ian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我的想法。
在我想出明显的解决方案之前,我多次阅读了这个问题。
我可以用 WatiN 读取 JavaScript 警报框吗?
这是我想出的代码。虽然如果警报没有发生,它确实会强制延迟 3 秒,但它非常适合我的场景。
希望其他人发现这有用..
Here's what I came up with.
I read this question several times before I came up with the obvious solution..
Can I read JavaScript alert box with WatiN?
This is the code I came up with.. While it does force a delay of 3 seconds if the alert doesn't happen, it works perfectly for my scenario.
Hope someone else finds this useful..