I believe I have accidentally discovered a bug with javscript pop-ups with how
watir-webdriver deals with errors. Please see the following examples:
### 1: No bad behavior means no error
```ruby
headless = Headless.new
headless.start
b = Watir::Browser.new :firefox
b.goto 'https://internal.site/'
b.execute_script("alert('Alert!');")
b.alert.ok
```
Result is nil -- everything went fine.
### 2: Trying to look at the HTML when you cannot means the modal is gone?
```ruby
headless = Headless.new
headless.start
b = Watir::Browser.new :firefox
b.goto 'https://internal.site/'
b.execute_script("alert('Alert!');")
alert_exists = b.alert.exists?
puts "alert_exists is #{alert_exists}" #=> "alert has 'alert'? true"
begin
page_html = Nokogiri::HTML.parse(b.html)
puts "page_html is #{page_html}" # Will never get called
rescue => e
puts "Error #{e} happened" #=> "Error Modal dialog present happened"
end
b.alert.ok
```
Result is:
```ruby
...
/.rvm/gems/ruby-2.0.0-p247/gems/watir-webdriver-0.6.4/lib/watir-webdriver/alert.rb:95:in
`rescue in assert_exists': unable to locate alert
(Watir::Exception::UnknownObjectException)
```
### 3: Trying to take a screenshot when you cannot means the modal is gone?
```ruby
headless = Headless.new
headless.start
b = Watir::Browser.new :firefox
b.goto 'https://internal.site/'
b.execute_script("alert('Alert!');")
alert_exists = b.alert.exists?
puts "alert_exists is #{alert_exists}" #=> "alert has 'alert'? true"
begin
b.screenshot.save 'thiswillnotsave'
rescue => e
puts "Screenshot error: #{e}" #=> "Screenshot error: Modal dialog
present"
end
b.alert.ok
```
Result, again, is:
```ruby
...
/.rvm/gems/ruby-2.0.0-p247/gems/watir-webdriver-0.6.4/lib/watir-webdriver/alert.rb:95:in
`rescue in assert_exists': unable to locate alert
(Watir::Exception::UnknownObjectException)
```
Is this a bug? If not, is it a setting I can disable?
#### FYI
I'm running CentOS 6.4 32 bit with Firefox 17, Headless 1.0.1, Watir-Webdriver
0.6.4, Selenium-Webdriver 2.37.0 driven by Ruby 2.0.0p247
---
Reply to this email directly or view it on GitHub:
https://github.com/watir/watir-webdriver/issues/226_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development