twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

Unexpected inner loop exception: missing keyword: has_browser_handler: #56

Closed yjukaku closed 4 years ago

yjukaku commented 4 years ago

Hello! Thanks for your work on this gem.

I'm working on getting my project running on CircleCI and I'm running into this exception. I saw this closed issue (#18) for a similar exception message, but in my case I believe it has to do with a dialog because the trace points to handling the Page.javascriptDialogOpening event.

There seems to be a required keyword argument here, has_browser_handler: which I'd guess is not being passed to Ruby (?):

@session.on 'Page.javascriptDialogOpening' do |type:, message:, has_browser_handler:, **params|
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/page.rb:428:in `block in register_event_handlers'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:211:in `block in process_handlers'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:207:in `each'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:207:in `process_handlers'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:185:in `block in process_messages'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:175:in `loop'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:175:in `process_messages'
/home/circleci/project/vendor/bundle/ruby/2.4.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:217:in `block in start_threads'

Any suggestions?

yjukaku commented 4 years ago

The method I'm calling which seems to trigger this exception is accept_confirm defined by Capybara.

This spec passes locally, but not on CircleCI, which is a little strange. I'm running with headless: true locally as well.

twalpole commented 4 years ago

It sounds like the versions of Chrome being tested against are probably different, or the CDP specification has changed

twalpole commented 4 years ago

@yjukaku Note - the docs for CDP show that hasBrowserHandler will be passed - https://chromedevtools.github.io/devtools-protocol/tot/Page/#event-javascriptDialogOpening

yjukaku commented 4 years ago

That's strange then that it's failing on CircleCI. Perhaps the option was added to CDP at a later point. Here's the image I'm using on CircleCI: https://github.com/CircleCI-Public/circleci-dockerfiles/blob/master/ruby/images/2.4.3-stretch/node-browsers/Dockerfile

I'm a newbie to Docker, but it looks to me that it installs a specific version of Chrome (chrome-stable_64.0.3282.186-1_amd64 but it also installs the latest version ofchromedriver... so that's probably the source of the issue, no? Chromedriver must have added that parameter, but the older version of Chrome is not passing it?

In any case, would you accept a PR that defaults the has_browser_handler keyword argument to false?

twalpole commented 4 years ago

@yiukaku Chrome 64 was released 2.5 years ago - Since chrome is an evergreen browser we aren't supporting versions that old. Therefore, no I won't be accepting PR that defaults has_browser_handler because there's tons of other stuff in CDP that won't work with a version of Chrome that old either. Also, the chromedriver versions needs to be matched to the version of Chrome you're using so using the latest chromedriver with a 2.5 year old Chrome isn't really going to work either.