I have one test case where after login, on some page when user tries to close the browser, it will show popup windows(alert) asking \"you might lose the data, are you sure you w
If I am understanding the problem correctly, then you are trying to perform a click on X to close the browser window which generates additional pop up. If that's the case, you can try executing some JavaScript
action to recreate the scenario
(( JavascriptExecutor ) webdriver).executeScript( "window.close()" );
instead of webdriver.close()
Note: Written in Java
More info: With the syntax above you can only close the child tab not the entire browser only IF it is invoked with
window.open()