TestProject Forum
Powered by leading experts in the test automation community

Launch browser once for entire test suite CodedUI

I have written a few tests with COdedUI testing a web app. I want to open the browser once in the solution and close it after all tests are done.

When I run tests while using AssemblyInitialize attribute on a method, with my BrowserWindow.Launch, it keeps throwing exception.

For some reason the code will work fine if its in a TestMethod.

What am I missing ?

If you use ClassInitialize, you have to initialize the playback engine with: Playback.Initialize();

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

Hope this helps.