This project is read-only.

Access Denied Exception when closing browser windows

Nov 21, 2012 at 6:01 PM

I'm getting an intermittent exception when trying to close the browser window. This intermittent issue just started happening after I picked up the latest code, prior to then i've never seen the issue.

Initialization method TejariAutomation.Tests.E2E_SmokeTest.TestInitialize threw exception. System.ComponentModel.Win32Exception: System.ComponentModel.Win32Exception: Access is denied.

CUITe.Controls.HtmlControls.CUITe_BrowserWindow.CloseAllBrowsers() in CUITe_BrowserWindow.cs: line 133

I'm not too sure what would be causing this issue. Visual Studio is running as Admin

Jan 17, 2013 at 9:26 AM

Hi ddoorn,

Can you provide some sample test code that can reproduce the problem please?

Thank you.

Jan 17, 2013 at 2:40 PM

I've stopped using that command since I ran into the problem. I wasn't using that code anywhere special, it seemed to happen randomly at random points in time and wasn't at all specific to my code.

Try creating a test that opens the browser, navigates somewhere and closes the browser, and repeat that test method a few times in a row and if you run it often enough you might hit the problem. I was using Visual Studio 2010 in windows 7 environment if that might make any difference.

The fact that the code you have kills the process isn't really ideal anyways since that won't preserve the browser settings (location, window size, whether it is maximized, etc) if any of that was altered during the test. I've created my own UI Map for the IE browser to click on the close button which seems to work much better.

Jan 19, 2013 at 7:58 PM

Sorry, I am not able to reproduce this issue.

If you want to close the browse window and preserve its position, size, and maximized setting, you can just simply call the .Close() method of the CUITe_BrowserWindow (derived) instance.

For example:

public void CloseBrowserWindow_UsingLaunchedBrowserWindow_Succeeds()
    TestHtmlPage window = CUITe_BrowserWindow.Launch<TestHtmlPage>(CurrentDirectory + "/TestHtmlPage.html");