编码的ui测试完成后,如何保持浏览器打开? [英] How do I keep the browser open after a coded ui test finishes?
问题描述
我正在对Web应用程序使用Visual Studio 2012编码的UI测试。我有一个测试,用于登录启动浏览器的应用程序,找到登录对话框,输入凭据,然后单击确定。我有一个断言,它在登录后检查正确的URL。该测试似乎正常运行。我的问题是,测试运行后它将关闭浏览器。我需要保持浏览器处于打开状态,以便可以按顺序运行下一个测试。我该怎么做?
I'm using Visual Studio 2012 Coded UI tests for a web application. I have a test for logging into the app which starts the browser, locates the login dialogue, enters credentials, and then clicks ok. I have an assertion which checks for the correct url after the login. This test appears to function correctly. My problem is that it closes the browser after the test runs. I need to keep the browser open, so I can run the next test in my sequence. How do I do this?
目前,我的[TestCleanup()]部分中没有任何内容。我以为我要寻找的东西就在这里,但是到目前为止我还没有很多运气来弄清楚那应该是什么。
At the moment, I don't have anything in my [TestCleanup()] section. I'm assuming that what I'm looking for goes here, but so far I haven't had a lot of luck figuring out what that is supposed to be.
推荐答案
我没有找到该解决方案的原始资源:(
您可以使用类似如下所示。需要在TestSetup中调用此方法,还要声明tyep BrowserWindow的类级变量_browserWindow
I don't have the original source where I found this solution :( You can have a method like the one showed below. This method needs to be called in TestSetup. Also declare a class level variable _browserWindow of the tyep BrowserWindow
private void SetBrowser()
{
if(_browserWindow == null)
{
BrowserWindow.CurrentBrowser = "ie";
_browserWindow = BrowserWindow.Launch("http://www.google.com");
_browserWindow.CloseOnPlaybackCleanup = false;
_browserWindow.Maximized = !_browserWindow.Maximized;
}
else
{
BrowserWindow.CurrentBrowser = "ie";
_browserWindow = BrowserWindow.Locate("Google");
_browserWindow.Maximized = !_browserWindow.Maximized;
}
}
这篇关于编码的ui测试完成后,如何保持浏览器打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!