Poltergeist throws JS errors when js_errors: false

后端 未结 3 734
醉话见心
醉话见心 2021-02-07 03:57

I have a large test suite that is using poltergeist and capybara. I keep getting the following error:

One or more errors were raised in the Javascript code on t         


        
3条回答
  •  有刺的猬
    2021-02-07 04:49

    I am not sure why your code doesn't work. I just had a similar JS error and did the following (as mentioned on this page (search for js_errors)) -- and basically what Leonardo Galani suggested (I upvoted Leonardo's answer to take it from -1 to 0):

    require 'capybara/poltergeist'
    Capybara.javascript_driver = :poltergeist
    
    options = {js_errors: false}
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, options)
    end
    

    I also tested this style, and it worked as well:

    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, {js_errors: false})
    end
    

    FWIW: My error (in Cucumber test) looked like this:

    Capybara::Poltergeist::JavascriptError: One or more errors were raised in the 
    Javascript code on the page. If you don't care about these errors, you can ignore 
    them by setting js_errors: false in your Poltergeist configuration (see 
    documentation for details).
    
    TypeError: Unable to delete property.
    TypeError: Unable to delete property.
        at :84
        at http://maps.gstatic.com/cat_js/maps-api-v3/api/js/17/20/%7Bmain,geometry%7D.js:19 in Ke
        at http://maps.gstatic.com/cat_js/maps-api-v3/api/js/17/20/%7Bmain,geometry%7D.js:19 in Ke
        at http://maps.gstatic.com/cat_js/maps-api-v3/api/js/17/20/%7Bmain,geometry%7D.js:18
    

提交回复
热议问题