0

I am trying to close the window but it is giving me javascript alert to click either "Leave" or "Stay".

I tried $browser.execute_script("window.confirm = function() {return true}") code, but it's not working.

2 Answers 2

1

Watir has a built-in Alert class. You could try browser.alert.ok

Sign up to request clarification or add additional context in comments.

Comments

0

execute this code:

window.onbeforeunload = null;

2 Comments

I ran it using this code "$browser.execute_script("window.onbeforeunload = null:")" but it is throwing this error "unexpected alert open: {Alert text : Having trouble getting a quote? We noticed you're leaving the page. If you're having trouble getting a quote, call us on 6221 2111, Mondays - Fridays. 8am - 8pm and we'll get you sorted. If you have an account with us, we will save your quote and it will be available in your Policy Manager.} (Session info: chrome=52.0.2743.116) (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2,platform=Windows NT 10.0 x86)"
The last symbol is ';'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.