Geeks With Blogs

News




View Tarun Arora's profile on LinkedIn

profile for Tarun Arora at Stack Overflow, Q&A for professional and enthusiast programmers

Tarun Arora - Visual Studio ALM MVP ALM, Agile, Automation, Performance Testing, Software QA, Cloud, ...

*** Thanks to Steve St. Jean for asking this question and Shubhra Maji for answering this question on the ALM champs list ***

01 – Introduction

The default behaviour of coded UI tests running in an Internet Explorer browser has changed between MTM 2010 and MTM 2012. When running a Coded UI test recorded in MTM 2012 or VS 2012 at the end of the test execution the instance of the browser is closed by default.

02 – Description

Let’s take an example. As you can see the CloseDinnerNowWeb() method is commented out.  In VS 2010, upon running this test the browser would be left open after the test execution completes.

image

In VS 2012 RTM the behaviour has changed. At the end of the test run, the IE window is closed even though there is no command from the test to do so. In the example below when the test runs, it opens 2 IE windows to the website. When the test run completes both the windows are closed, even though there is no command in the test to close the window.

image

03 – How to change the CUIT behaviour not to close the IE window after test execution?

This change to this functionality in VS 2012 is by design. It is however possible to rollback the behaviour to how it originally was in VS 2010 i.e. the IE window will not close after the test execution unless otherwise commanded by the test to do so.

To go back to the original functionality, set BrowserWindow.CloseOnPlaybackCleanup = false

More details on the CloseOnPlaybackCleanup property can be found here http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.applicationundertest.closeonplaybackcleanup.aspx 

HTH     Be right back

 

Posted on Thursday, September 20, 2012 11:49 PM TFS2012 , MTM | Back to top


Comments on this post: VS2012 Coded UI Test closes browser by default

# re: VS2012 Coded UI Test closes browser by default
Requesting Gravatar...
Hi

Interesting post, however when I use it it does not work. I pass the BrowserWindow.CloseOnPlaybackCleanup = false and even debugs it to make sure it is actually false but the browser still closes after the test. This happens when I use BrowserWindow.LaunchUrl(Uri uri)

Any thoughts on this?
Left by Peter on Oct 01, 2012 10:57 PM

# re: VS2012 Coded UI Test closes browser by default
Requesting Gravatar...
Never mind, I figured it out. Turns out you have to create a new browser object in [TestInitialize] and set the flag on that one, it didn't work when I tried doing it on the one being created on the map.

Anyway, your post really helped me solve it, thanks!
Left by Peter on Oct 02, 2012 1:07 PM

# re: VS2012 Coded UI Test closes browser by default
Requesting Gravatar...
One more thing, in order to keep using the same browser window you have to pass it along to the next method by using e.g. he Locate method
Left by Peter on Oct 22, 2012 8:29 PM

comments powered by Disqus

Copyright © Tarun Arora [Microsoft MVP] | Powered by: GeeksWithBlogs.net