CodedUI tests - start a browser once for the entire set of tests

佐手、 提交于 2020-01-12 06:56:12

问题


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.

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:

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.

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.

Thanks!


回答1:


If using ClassInitialize, you need to initialize the playback engine with Playback.Initialize()

  [ClassInitialize]
  public static void LaunchBroswer(TestContext context)
  {         
     Playback.Initialize(); 
     BrowserWindow browser = BrowserWindow.Launch(new System.Uri("about:blank"));
  }



回答2:


 BrowserWindow uatwebjetcomauBrowser = BrowserWindow.Launch(new System.Uri(this.LaunchBrowserParams.Url));


来源:https://stackoverflow.com/questions/7150534/codedui-tests-start-a-browser-once-for-the-entire-set-of-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!