弹出的华廷测试 [英] WatiN testing of a popup
问题描述
我有带来了当你点击一个链接弹出窗口的应用程序。我有一个华廷测试naviates到页面,点击一个链接打开弹出窗口。这是我当前的代码:
I have an application that brings up a popup window when you click a link. I have a watin test that naviates to the page and clicks a link to open the popup. This is my current code:
[Test]
public void TestCommentBoxInput()
{
window.GoTo("mylocalurl");
window.Link(Find.ById("popuplink.aspx")).Click();
IE iepopup_1 = IE.AttachTo<IE>(Find.ByUrl("popuplinkurl.aspx"));
iepopup_1.TextField(Find.ById("txtComments")).TypeText("Commenttest");
}
正如你可以看到我试着attatching的弹出窗口被称为窗口创建的浏览器。当我运行我的测试,它只是停止在弹出的窗口中,从来没有进入在框中的文字。我如何去让我的程序regonize,这是现在要在弹出操作,而不是原来的窗口
As you can see I tried attatching the popup window to the created browser called window. When I run my test it just stops at the popup window and never enters text in the box. How do I go about making my program regonize that it is now to be operating on the popup and not the original window?
编辑:我正在处理一个模态对话框。
I am dealing with a Modal Dialog.
推荐答案
所以我想通了这个问题,这个问题是我使用的是模态对话框,并处理它们的不同。我的新代码如下万一有人被卡在同一位置我在。)
So I have figured out the problem, the problem was I was using a Modal dialog and they are handled differently. My new code is as follows in case anyone is stuck in the same position I was in. :)
public void TestCommentBox()
{
window.GoTo("mylocalurl");
window.Link(Find.ById("popuplink.aspx")).ClickNoWait();
HtmlDialog dialog = window.HtmlDialog(Find.ByTitle("TestPopup"));
dialog.TextField(Find.ById("Txtcomments")).TypeText("Commmenttest!");
}
重要的线路有:
The important lines are:
window.Link(Find.ById("popuplink.aspx")).ClickNoWait();
请注意,我用的ClickNoWait(),而不是只要按一下,我不清楚为什么这使得的差,但它确实!如果有人可以解释,这将是巨大的。
Notice that I am using ClickNoWait() and not just Click, I am unsure as to why this makes the difference, but it does! If someone could explain that that would be great.
HtmlDialog dialog = window.HtmlDialog(Find.ByTitle("TestPopup"));
由于我处理的,你必须声明一个新HtmlDialog一个模态对话框。另外为了使用HTML对话框确保您有Watin.Core.DialogHandlers。我希望这是有帮助的人在那里! :)
Because I am dealing with a Modal dialog you have to declare a new HtmlDialog. Also in order to use Html dialog make sure you include Watin.Core.DialogHandlers. I hope this is helpful to someone out there! :)
这篇关于弹出的华廷测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!