Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capybara::Apparition::CDPError Invalid parameters #75

Open
yjukaku opened this issue Mar 10, 2021 · 1 comment
Open

Capybara::Apparition::CDPError Invalid parameters #75

yjukaku opened this issue Mar 10, 2021 · 1 comment

Comments

@yjukaku
Copy link

yjukaku commented Mar 10, 2021

Hello there! Thanks for your work on this gem.

I'm running into an issue intermittently when trying to click on an element in an RSpec spec. Using debugger I was able to get more details about the error.

Here's the error that I get via rspec:

  1) The description of our spec :)
     Failure/Error: super

     Capybara::Apparition::CDPError:
       Invalid parameters
     # ./spec/support/capybara_patches.rb:20:in `synchronize'
     # ./spec/features/our_spec.rb:292:in `block (4 levels) in <top (required)>'
     # ./spec/features/our_spec.rb:291:in `block (3 levels) in <top (required)>'
     # ./spec/features/our_spec.rb:133:in `block (3 levels) in <top (required)>'
     # ./spec/support/database_cleaner.rb:38:in `block (2 levels) in <main>'

Not very helpful, haha. But I added a debugger call to the Apparition gem, and was able to get some more details:

[10, 19] in /Users/me/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/response.rb
   10:       end
   11:
   12:       def result
   13:         response = @msg_ids.map do |id|
   14:           resp = @client.send(:wait_for_msg_response, id)
=> 15:           handle_error(resp['error']) if resp['error']
   16:           resp
   17:         end.last
   18:         puts "Processed msg: #{@msg_ids.last} in #{Time.now - @send_time} seconds" if ENV['DEBUG'] == 'V'
   19:
(byebug) resp
{"id"=>5713, "error"=>{"code"=>-32602, "message"=>"Invalid parameters", "data"=>"Failed to deserialize params.y - BINDINGS: double value expected at position 57"}}
(byebug) up

[8, 17] in /Users/me/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/response.rb
    8:         @msg_ids = msg_ids
    9:         @client = client
   10:       end
   11:
   12:       def result
=> 13:         response = @msg_ids.map do |id|
   14:           resp = @client.send(:wait_for_msg_response, id)
   15:           handle_error(resp['error']) if resp['error']
   16:           resp
   17:         end.last
(byebug) up

[360, 369] in /Users/me/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/apparition-0.5.0/lib/capybara/apparition/page.rb
   360:       wait_for_loaded
   361:       _raw_evaluate('document.title')
   362:     end
   363:
   364:     def command(name, **params)
=> 365:       @browser.command_for_session(@session.session_id, name, params).result
   366:     end
   367:
   368:     def async_command(name, **params)
   369:       @browser.command_for_session(@session.session_id, name, **params).discard_result
(byebug) name
"Input.dispatchMouseEvent"
(byebug) params
{:type=>"mouseMoved", :button=>"none", :buttons=>0, :x=>975.46875, :y=>0.377334671020507825e3, :modifiers=>0, :clickCount=>1}
(byebug) params[:y]
0.377334671020507825e3
(byebug) params[:y].class
BigDecimal
(byebug) params[:x].class
Float
(byebug)

So it looks like the error details are:

"error"=>{"code"=>-32602, "message"=>"Invalid parameters", "data"=>"Failed to deserialize params.y - BINDINGS: double value expected at position 57"}

I guess somehow the y value of 0.377334671020507825e3 (which is a Ruby BigDecimal) is not able to be deserialized by CDP? Does that seem right?

I wonder if rounding that to the closest integer would help? Is there any reason to keep the decimal version of the coordinates when firing mouse events?

@twalpole
Copy link
Owner

I'm sorry I haven't had any of time to give the attention to apparition it needs, and have prioritized the small amount of free time I have had to Capybara. I'm willing to look at any PRs here but beyond that don't know when I'll be able to put more time towards apparition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants