Chrome driver not performing specified teardown method at end of test

I have a test case that takes the variables shouldLogout and shouldCloseBrowser, both set to true by default. I also have a teardown method that looks like this :

@TearDown(skipped = false)

def tearDown() {

if (shouldLogout) {

WebUI.click(findTestObject('Object Repository/Page_Sign In/li_Sign Out'))

}

if (shouldCloseBrowser) {

WebUI.closeBrowser()

}

`}

`

In Firefox, when I run this test, everything goes according to plan: the test runs and, regardless of its end state, it logs out of the app and shuts down the driver. However, when I run this in Chrome, not only does the browser stay open, but the session is still logged in! I took no actions on the Chrome window. What is causing this?!

Are you using this for a test suite or a test case?

Not sure, But you can probably bypass it with a “If-then statement”, having it WebUI.closeBrowser()

@Mate Mrse

I am using this for a test case.

As for this issue, I haven’t encountered it again.