When we run our first CodedUI test method we notice that system closes the browser after finishing the test method and we just wonder why it closes the browser. So answer is, CodedUI framework has been designed like that only where it closes the browser after finishing the tasks.

Same framework has provided an option where we can choose not to close browser after finishing the tasks and that option is ‘CloseOnPlaybackCleanup’ property. By using this property we can make sure that browser should not close after completing the tasks.

However, in most of cases Tester writes only a method and uses CloseOnPlaybackCleanup=false and thinks that framework should not close the browser but it does not work in this way.

CloseOnPlaybackCleanup=false says that if you have more than 1 test methods and then framework will not close the browser after the first method, it will complete all test methods tasks and then only it closes the browser. So where tester has only 1 [TestMethod] with CloseOnPlaybackCleanup=false and CodedUI closes the browser there it is working as expected.

Use below code to test it out-

CloseBrowser

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s