See http://watirwebdriver.com/javascript-dialogs/  under the Alternative 
Method

Here's an example implementation:

require 'watir-webdriver'

browser = Watir::Browser.new :safari
browser.goto 'http://the-internet.herokuapp.com/javascript_alerts'
browser.execute_script("window.alert = function() {}")
browser.button(:text => 'Click for JS Alert').click
puts Watir::Wait.until { browser.text.include? "You successfuly clicked an 
alert" }


You won't see the alert display at all


On Monday, July 21, 2014 4:13:43 PM UTC-4, Dimitri Reynaga wrote:
>
> While using the watir safari webdriver, the webdriver terminates as soon 
> as it encounters an alert pop-up. Are there any workarounds that will 
> either allow Safari webdriver to function properly with alerts, or to 
> prevent the alerts from appearing at all?
>
>     $driver.button(:xpath, "//button[@class='btn btn-success 
> btn-success-red']").wait_until_present
>     $driver.button(:xpath, "//button[@class='btn btn-success 
> btn-success-red']").click
>
>     $driver.alert.ok()
>   $log.info("create organization successful")
>
> error:
>
>
> /Users/usr/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/safari/bridge.rb:73:in
>  raw_execute': 
> A modal dialog was opened. The SafariDriver does not support interacting 
> with modal dialogs. To avoid hanging your test, the alert has been 
> dismissed. For more information, see 
> http://code.google.com/p/selenium/issues/detail?id=3862 
> (Selenium::WebDriver::Error::UnhandledAlertError) from 
> /Users/usr/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/bridge.rb:612:in
>  
> execute' from 
> /Users/usr/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/bridge.rb:369:in
>  clickElement' 
> from 
> /Users/usr/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/common/element.rb:54:in
>  
> click' from 
> /Users/usr/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.10/lib/watir-webdriver/elements/element.rb:132:in
>  click' 
> from /Users/usr/Documents/workspace/TTQA 
> Safari/tttestlibrary.rb:47:increate_org' 
> from /Users/usr/Documents/workspace/TTQA Safari/ttorgusercompare.rb:23:in 
> org_user_compare' 
> from /Users/usr/Documents/workspace/TTQA Safari/ttorgusercompare.rb:34:in'
>
> Thanks!
>
>

-- 
-- 
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