I just meant that you don't need that line with Firefox.

Firefox:

begin
    browser.goto "https://www.facebook.com";
rescue UnhandledAlertError
   # Do nothing, Firefox already did it.
end

Chrome:

begin
    browser.goto "https://www.facebook.com";
rescue UnhandledAlertError
    browser.alert.ok
end

Either:

begin
    browser.goto "https://www.facebook.com";
rescue UnhandledAlertError
    browser.alert.ok if browser.alert.exists?
end


On Tue, Jul 21, 2015 at 9:31 AM, Eihiko O <[email protected]> wrote:

> Okay, I can switch to chrome. Thank you!
>
> On Tuesday, July 21, 2015 at 9:47:08 AM UTC-4, Titus Fortner wrote:
>>
>> Yes, I saw this behavior when working on the error checkers. We discussed
>> it here:
>> https://github.com/watir/watir-webdriver/issues/280#issuecomment-59587241
>>
>> Your code would work fine for Chrome, but Firefox always closes the alert
>> when it throws the error.
>>
>> Titus
>>
>>
>> On Jul 21, 2015 8:31 AM, "Eihiko O" <[email protected]> wrote:
>>
>>> Hi all,
>>>
>>> I'm using watir-webdriver with firefox and Ruby 2.0.0. I'm trying to use
>>> browser.goto() to redirect away from a (facebook) page with unsubmitted
>>> text. An "are you sure you want to navigate away from this page?" alert
>>> pops up, which causes an UnhandledAlertError to be thrown. I tried handling
>>> the error with code along these lines:
>>>
>>> begin
>>>     browser.goto "https://www.facebook.com";
>>> rescue UnhandledAlertError
>>>     browser.alert.ok
>>> end
>>>
>>> But this does not work because for some reason, the alert is being closed 
>>> before my rescue code can handle it. Any idea what might be causing it?
>>>
>>>  --
>>> --
>>> Before posting, please read http://watir.com/support. In short: search
>>> before you ask, be nice.
>>>
>>> [email protected]
>>> http://groups.google.com/group/watir-general
>>> [email protected]
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Watir General" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>   --
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to