I've written a blog post on this:
http://watirmelon.com/2010/10/31/dismissing-pesky-javascript-dialogs-with-watir/

and updated the wiki:  http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups

Cheers,
Alister

On Sat, Oct 30, 2010 at 7:52 AM, Alister Scott <alister.sc...@gmail.com>wrote:

> Any ideas why my code won't work in FireWatir?
>
> Cheers, Alister.
>
> On 30/10/2010, at 6:47 AM, Jari Bakken <jari.bak...@gmail.com> wrote:
>
> watir-webdriver has a decent Ruby API for this as an optional require:
>
>
> <http://github.com/jarib/watir-webdriver/blob/master/lib/watir-webdriver/extensions/alerts.rb>
> http://github.com/jarib/watir-webdriver/blob/master/lib/watir-webdriver/extensions/alerts.rb
>
> Feel free to use it in Watir. I might change it when WebDriver provides its
> own solution though.
>
> Den 29. okt. 2010 kl. 21:23 skrev Bret Pettichord < <b...@pettichord.com>
> b...@pettichord.com>:
>
> You can add the technique to this page:
>
> <http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups><http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups>
> http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups
>
> Bret
>
> On Thu, Oct 28, 2010 at 11:42 PM, Alister Scott 
> <<alister.sc...@gmail.com><alister.sc...@gmail.com>
> alister.sc...@gmail.com> wrote:
>
>> I forgot to mention, I can't get this working in Firefox, only IE at the
>> moment.
>>
>> Cheers,
>> Alister
>>
>>
>> On Fri, Oct 29, 2010 at 12:16 PM, Alister Scott 
>> <<alister.sc...@gmail.com><alister.sc...@gmail.com>
>> alister.sc...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> One of the guys I am working with setting up Cucumber and Watir on a
>>> ThoughtWorks project told me about a way to get rid of the pesky JavaScript
>>> dialogs that cause Watir scripts to be unstable. It involves overriding the
>>> JavaScript function to always return true, so the dialogs never appear.
>>>
>>> I wrote an example for Watir:
>>>
>>> require 'rubygems'
>>> require 'watir'
>>> b = Watir::Browser.start 
>>> "<http://www.sislands.com/coin70/week1/dialogbox.htm><http://www.sislands.com/coin70/week1/dialogbox.htm>
>>> http://www.sislands.com/coin70/week1/dialogbox.htm";
>>> b.execute_script "window.confirm = function() { return true; }"
>>> b.execute_script "window.alert = function() { return true; }"
>>> b.execute_script "window.prompt = function() { return true; }"
>>> b.button(:value => 'confirm').click
>>>
>>>
>>> What do you think of this? Is it worthwhile putting this out for Watir
>>> users to see and use?
>>>
>>> Cheers,
>>>
>>> Alister Scott
>>> Brisbane, Australia
>>> Watir Web Master: <http://watir.com> <http://watir.com>http://watir.com
>>> Blog: <http://watirmelon.com> <http://watirmelon.com>
>>> http://watirmelon.com
>>> LinkedIn: 
>>> <http://www.linkedin.com/in/alisterscott><http://www.linkedin.com/in/alisterscott>
>>> http://www.linkedin.com/in/alisterscott
>>>
>>> "There are two ways to get enough: One is to continue to accumulate more
>>> and more. The other is to desire less." *~ G. K. Chesterton*
>>>
>>
>>
>> _______________________________________________
>> Wtr-development mailing list
>>  <Wtr-development@rubyforge.org> <Wtr-development@rubyforge.org>
>> Wtr-development@rubyforge.org
>>  
>> <http://rubyforge.org/mailman/listinfo/wtr-development><http://rubyforge.org/mailman/listinfo/wtr-development>
>> http://rubyforge.org/mailman/listinfo/wtr-development
>>
>
>
>
> --
> Bret Pettichord
> Lead Developer, Watir, <http://www.watir.com> <http://www.watir.com>
> www.watir.com
>
> Blog, <http://www.io.com/%7Ewazmo/blog> <http://www.io.com/%7Ewazmo/blog>
> www.io.com/~wazmo/blog <http://www.io.com/%7Ewazmo/blog>
> Twitter, 
> <http://www.twitter.com/bpettichord><http://www.twitter.com/bpettichord>
> www.twitter.com/bpettichord
>
> _______________________________________________
> Wtr-development mailing list
> <Wtr-development@rubyforge.org>Wtr-development@rubyforge.org
>  <http://rubyforge.org/mailman/listinfo/wtr-development>
> http://rubyforge.org/mailman/listinfo/wtr-development
>
> _______________________________________________
> Wtr-development mailing list
> Wtr-development@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-development
>
>
_______________________________________________
Wtr-development mailing list
Wtr-development@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to