battleship
battleship

Reputation: 353

Selenium Ruby Webdriver - how to close IE9 browser session with popup displayed

I'm doing some modifications on a page in my web application, this results in a popup message displayed "This page is asking you to confirm that you want to leave - data you have entered may not be saved" with two buttons "Leave Page" and "Stay on Page".

I can close my web application if using FF16 or Chrome with below code:

   @driver.quit

However, I cannot close if I'm opening my web application on the browser IE9 (it means that I can open another IE9 browser session, but the browser session with popup message displayed is NOT closed).

I'm using Selenium Ruby Webdriver. Please help guide me a solution to resolve this problem. Thanks much.

Upvotes: 2

Views: 674

Answers (1)

battleship
battleship

Reputation: 353

I found out the expected answer for my question at: https://stackoverflow.com/a/7034926/1385187 (Thanks so much for this great answer).

( ( JavascriptExecutor ) _driver ) .executeScript( "window.onbeforeunload = function(e){};" );

Upvotes: 2

Related Questions