Friday 15 May 2015

ruby on rails - How to Test JavaScript error in Capybara/Poltergeist -


I have to check that the page has a JavaScript error.

CAPBRARA-WEBKIT solution

'Prec_helper' feature 'Home' is required 'Javascript errors should not be' ,: JS => expect true (root_path) (page) .not_to has_errors end end

How do you look the same for one?

spec_helper.rb

  ... 'capybara / rails' is required 'capibara / selenium / driver' ... selenium_hb_host = "selenium" selenium_hub_port = " 100 "selenium_url =" http: // # selenium_hub_host}: # {selenium_hub_port} / wd / hub "... capebara Registrar: selenium_remote do | App | Options = {} Option [: Browser] =: Remote Capabilities = Selenium :: WebDriver :: Remote :: Capabilities Firefox capabilities [: platform] =: any ability [: le_sertence] = true option [: url] = selenium_url option [: desired_capabilities] = abilities capybara :: selenium :: driver. New (app, option) end Capybara.javascript_driver =: selenium_remote Capybara.default_max_wait_time = 30 Capybara.server do | App, harbor | Rack / Handler / Thin 'Rack :: Handler :: Thin. Roun (app, host = & gt; 0.0.0.0 ',: port = & gt; port) end is required ...  

Try this configuration:

  Capybara.register_driver: poltergeist do | App | Capybara :: Poltergeist :: Driver.new (app, {debug: true, poltergeist debug mode js_errors is turned on: true, turn on javascript errors on page timeout: 10000, pretz_pection: ['- load-images = yes',' --ignore-ssl-errors = yes', '-ssl-protocol = any']}) end cabiber. Javascript_driver =: poltergeist Capybara.current_driver =: poltergeist Capybara.default_wait_time = 5 Capybara.server_port = '3000' Capybara.app_host = "http://127.0.0.1:3000"  

images Loading and Pottage Debug mode if you do not need it.

In BTW, Capepara does not contain a has_errors matures. To use that maiture, you must use the Capibera-Webkit gem / driver instead of selenium

< P> If you use the PhantomJS / Pottage Registry with Cappaber to run your test, this test will fail and will output any error (including JS errors) ...

Also It will also output JS alerts, Which does not fail the test, but still gives visibility of the disturbances in your site ...

If JS errors are a great deal to test your product, then I use it By doing teaspoon ... ...

I suggest suggestions about Selenium WD, this is nothing for monitoring JS, on the given page errors are special tools given there. ..


No comments:

Post a Comment