WatiN两级模态对话框

时间:2010-05-31 13:58:28

标签: modal-dialog watin

我正在使用WatiN lib进行自动化测试。但有些情况下我必须访问一个模态对话框,这是另一个模态对话框。上面的代码工作正常,但最后一行再次打开一个modaldialog。我无法使用ie实例访问它..任何想法?

        IE ie = new IE("http://localhost/test.htm");
        ie.Link("main_lnk1").ClickNoWait();

        HtmlDialog dialog = ie.HtmlDialog(Find.ByTitle("Modal 1")));

        dialog.TextField("modal1_txt1").Value = "modal 1";
        dialog.Link("modal1_lnk1").ClickNoWait();

1 个答案:

答案 0 :(得分:0)

我发现了这种煽动的解决方法..

    IE ie = new IE("http://localhost/test.htm");
    ie.Link("main_lnk1").ClickNoWait();

    HtmlDialog dialog = ie.HtmlDialog(Find.ByTitle("Modal 1")));

    string modalUrl = dialog.Url;
    dialog.Close();
    IE ie2 = new IE(modalUrl);
    ie2.TextField("modal1_txt1").Value = "modal 1";
    ie2.Link("modal1_lnk1").ClickNoWait();

    HtmlDialog dialog = ie2.HtmlDialog(Find.ByTitle("Modal 2")));