title: Invoke browser X button with JavaScript
body: <p>This question is brought up because of <a href="https://stackoverflow.com/questions/29054134/how-to-close-the-browser-by-rejecting-popup-window-in-selenium-webdriver/29055017?noredirect=1#comment46347555_29055017">this</a>. The problem is, probably, the page is designed to generate a confirmation alert only if the user click on browser <strong>X</strong> button. I know that <code>window.close()</code> will close the current browser window which <em>probably</em> is not the same as clicking the <strong>X</strong> of browser window. Is there any way, possibly with JavaScript to recreate the click action on browser <strong>X</strong> button as if a real user would do?</p>