问题
Phantom JS Version: 1.9.1 Poltergeist Version: 1.3.0
Starting today youtube embedded videos now give a poltergeist error when running javascript tests. My youtube code is just the default embed youtube code. Here's a example:
<iframe width="560" height="315" src="//www.youtube.com/embed/AW9Z3cGOlGM?rel=0" frameborder="0" allowfullscreen></iframe>
And the errors I get just from visiting that page while enabling javascript is:
Failure/Error: page.find(".container.registrations.false.government")["style"].should have_content("test.jpg")
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: 'null' is not an object (evaluating 'a.dataset')
at http://s.ytimg.com/yts/jsbin/www-embed-player-vfl6vSff7.js:97
at http://s.ytimg.com/yts/jsbin/www-embed-player-vfl6vSff7.js:88 in vg
at http://s.ytimg.com/yts/jsbin/www-embed-player-vfl6vSff7.js:85
at http://s.ytimg.com/yts/jsbin/www-embed-player-vfl6vSff7.js:98
Also in some tests poltergeist just dies..
Failure/Error: visit root_path
Capybara::Poltergeist::DeadClient:
PhantomJS client died while processing {"name":"visit","args":["http://subdomain13.lvh.me:3003/"]}
Additionally it does not ignore these errors when doing:
Capybara.register_driver :poltergeist_without_js do |app|
Capybara::Poltergeist::Driver.new(app, :js_errors => false)
end
Capybara.javascript_driver = :poltergeist_without_js
回答1:
It's a bug in the embed JS handling browsers that don't support flash or html5 video:
Discussion at https://productforums.google.com/d/topic/youtube/2Cu87teAGYE/discussion
Bug report at https://code.google.com/p/gdata-issues/issues/detail?id=5883
来源:https://stackoverflow.com/questions/21438826/phantom-js-error-with-youtube-video