teodesian / Selenium-Remote-Driver

Perl Bindings to the Selenium Webdriver server
174 stars 90 forks source link

Double click broken - here's a fix. #454

Closed Stringer26 closed 4 years ago

Stringer26 commented 4 years ago

Double click is broken. There are 2 bugs. One is obvious and the other puzzles me a bit.

Using chrome $driver->double_click gives the following error:

Error while executing command: invalid argument: invalid argument
from invalid argument: 'button' must be a non-negative int and between 0 and 4
  (Session info: chrome=86.0.4240.183) at /usr/local/share/perl5/5.32/Selenium/Remote/Driver.pm line 403.
 at /usr/local/share/perl5/5.32/Selenium/Remote/Driver.pm line 353.

What's happening is that the button number is being sent as the string "0" rather than 0. A brutal fix is to replace line 1613 of Driver.pm with $button = int(_get_button($button)); I must admit I'm not sure why this is necessary.

After doing this one gets another bug.

 Error while executing command: unknown command: unknown command: Cannot call non W3C standard command while in W3C mode at /usr/local/share/perl5/5.32/Selenium/Remote/Driver.pm line 404.
 at /usr/local/share/perl5/5.32/Selenium/Remote/Driver.pm line 354.

This one's obvious. You need to add return 1; after line 1675 in Driver.pm.

Firefox doesn't suffer from the first bug but it is by the second one.

teodesian commented 4 years ago

int() is due to the way JSON gets encoded and sent over the wire, along with driver authors not being particularly careful with their inputs and doing the coercions like they used to.

I'll build a patch based on these suggestions soon.