5

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
Tom Prats
  • 7,364
  • 9
  • 47
  • 77
  • Not a great solution, but we ended up having to make sure that our embedded videos only showed up due to a user interaction to prevent phantom from attempting to run the ytimg code. This made our tests pass (and let us deploy). – Kyle Jan 29 '14 at 19:08
  • Yeah, right now I'm using ` – Tom Prats Jan 29 '14 at 19:11
  • This randomly started happening in my tests just now, but doesn't happen in the browser. Can't work out why. I'm specifically testing YouTube embeds, so can't ignore it. :-/ – Matt Gibson Jan 30 '14 at 11:30
  • 1
    Looks like a JS error in YouTube's embedding fallback code: https://productforums.google.com/forum/?hl=en#!category-topic/youtube/chrome/2Cu87teAGYE – Matt Gibson Jan 30 '14 at 11:35

1 Answers1

2

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

Jordan Liggitt
  • 16,933
  • 2
  • 56
  • 44