控制一个我没有启动的窗口

时间:2013-08-02 10:09:01

标签: c# white

我正在用TestStack White编写一个简单的安装脚本,所以我可以学习框架(我没有在网上找到很多信息)。

我正在使用传奇安装联盟进行这个小实验

填写表单后,按下下一个按钮,会出现一个从安装程序打开的窗口。

我想知道是否有办法获取窗口,即使我不是执行它的人。

这是我用来运行应用程序的代码,直到新窗口打开的那一刻:

private void pressXButton(White.Core.UIItems.WindowItems.Window currentWindow, string buttonName)
    {
        var xButton = currentWindow.Get<White.Core.UIItems.Button>(White.Core.UIItems.Finders.SearchCriteria.ByText(buttonName));
        xButton.Click();
        currentWindow.WaitWhileBusy();
    }

    public void RunScript()
    {
        White.Core.Application application = White.Core.Application.Launch(filePath);
        White.Core.UIItems.WindowItems.Window window = application.GetWindow(windowTitle);
        window.WaitWhileBusy();

        pressXButton(window, NEXT_BUTTON_TEXT);

        var radioButtonAgree = window.Get<White.Core.UIItems.RadioButton>(White.Core.UIItems.Finders.SearchCriteria.ByText("I accept the terms in the License Agreement"));
        radioButtonAgree.Select();
        window.WaitWhileBusy();

        pressXButton(window, NEXT_BUTTON_TEXT);
        pressXButton(window, NEXT_BUTTON_TEXT);
        pressXButton(window, NEXT_BUTTON_TEXT);
        pressXButton(window, NEXT_BUTTON_TEXT);
        pressXButton(window, NEXT_BUTTON_TEXT);
        pressXButton(window, "Install");

//afther pressing the Install Button the program ask to install  Microsoft Visual C++ 2005 Redistributable Package and here is where im stcuk




    }

(对不起我的英文)

1 个答案:

答案 0 :(得分:1)

您可以使用Desktop.Instance.Windows()来获取所有窗口,而不仅仅是您正在测试的过程中的窗口。

否则,您必须使用Application.Attach(“processname”)来获取Microsoft Visual C ++ 2005 Redistributable Package的过程