Pages

Friday, March 25, 2011

CodedUI Test Close Browser

I am testing a web application and some error messages are generated through JavaScript. I created a Coded UI test that verified the error messages when the user attempts to login with an empty username or an empty password. I couldn't use a Web Performance Test because the JavaScript is not executed during playback.

I forgot to record closing the browser, so I added it under TestCleanup.

Here is what I changed in the CodedUI Test:

1) click + to expand the Additional test attributes region
2) Un-comment the TestCleanup method
3) add a line to close the browser: "this.map.UIMSNcomWindowsInterneWindow.Close();"

[TestCleanup()]
        public void MyTestCleanup()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.map.UIMSNcomWindowsInterneWindow.Close();
        }

No comments: