Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebDriver close Internet Explorer after test

I'm running WebDriver tests in Ruby and I've got a problem with closing Internet Explorer browser: when I suppose to close browser's window, IE pop-ups with the prompt "Are you sure want to leave this page" and two options are available "Leave this page" and "Stay on this page".

I've tried several methods for closing browser, both without success:

driver.quit
driver.close

Also WebDriver doesn't recognize this pop-up as JavaScript pop-up so

driver.alert.ok 
driver.switch_to.alert

methods are also not applicable. I'm using IE9 and IEDriverServerx86 v. 2.24.2

I appreciate any help you can provide

like image 621
Alexander Sirobaba Avatar asked Jun 04 '26 13:06

Alexander Sirobaba


1 Answers

You need to suppress the onbeforeunload event first:

driver.execute_script "window.onbeforeunload = function(e){};"
driver.quit
like image 164
Strelok Avatar answered Jun 06 '26 04:06

Strelok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!