Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 17th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'watir-webdriver'
  2.  
  3. profile = Selenium::WebDriver::Firefox::Profile.new
  4. profile.log_file = "/tmp/firefox.log"
  5.  
  6. d = Watir::Browser.new :firefox, :profile => profile
  7. d.goto "data:text/html;content-type=utf-8,#{URI.encode DATA.read}"
  8. d.quit
  9.  
  10. Dir['/tmp/firefox*.log'].each do |file|
  11.   p :file => file, :has_client_error => File.read(file).include?('oops')
  12. end
  13.  
  14. # output:
  15. #
  16. # {:file=>"/tmp/firefox-1.log", :has_client_error=>false}
  17. # {:file=>"/tmp/firefox.log", :has_client_error=>true}
  18. #
  19.  
  20. __END__
  21. <html>
  22.   <body>
  23.     <script>
  24.       throw new Error('oops');
  25.     </script>
  26.   </body>
  27. </html>