CodedUI测试 - 启动浏览器一次整组试验
我在VS2010写一些codedUI测试来测试Web应用程序。我希望能够打开浏览器的一次作为整套解决方案中的测试,然后再关闭它当测试完成。
I'm writing some codedUI tests in VS2010 to test a web application. I'd like to be able to open the browser once for the entire set of tests in the solution and then close it again when the tests finish.
我试过 AssemblyInitialize
上的方法属性,我的 BrowserWindow.Launch
在那里,但它给了我,当我运行了以下异常:
I've tried AssemblyInitialize
attribute on a method, with my BrowserWindow.Launch
in there, but it gives me the following exception when I run it:
大会初始化方法OrdersGridTesting.SuiteSetup。登录
抛出异常。
Microsoft.VisualStudio.TestTools.UITest.Extension.TechnologyNotSupportedException:
Microsoft.VisualStudio.TestTools.UITest.Extension.TechnologyNotSupportedException:
中的浏览器目前不支持..中止测试执行
Assembly Initialization method OrdersGridTesting.SuiteSetup.Login threw exception. Microsoft.VisualStudio.TestTools.UITest.Extension.TechnologyNotSupportedException: Microsoft.VisualStudio.TestTools.UITest.Extension.TechnologyNotSupportedException: The browser is currently not supported.. Aborting test execution.
这相同的代码工作正常,当我把它变成一个 TestMethod的
,这使我相信,这是不可能的。有人建议,如果让这样做的另一种方法?我想不涉及,加入相同的代码来测试每类项目如果可能的方法。
This same code works fine when I put it into a TestMethod
, which leads me to believe that this isn't possible. Can someone suggest another method of doing this if so? I'd like a method that doesn't involve adding the same code to every test class in the project, if possible.
谢谢!
如果使用 ClassInitialize
,你需要用来初始化播放引擎回放.Initialize()
[ClassInitialize]
public static void LaunchBroswer(TestContext context)
{
Playback.Initialize();
BrowserWindow browser = BrowserWindow.Launch(new System.Uri("about:blank"));
}