MinkSelenium2Driver icon indicating copy to clipboard operation
MinkSelenium2Driver copied to clipboard

No WebDriver\Session::moveto() call when dragging onto itself

Open mvorisek opened this issue 3 years ago • 15 comments

This fixes dragging over itself, ie. source element = destination element, in such usecase, extra WebDriver\Session::moveto() call is redundant.

Drag library like https://github.com/Shopify/draggable needs this fix as the source element is very often transformed when dragging and WebDriver\Session::moveto() is failing otherwise.

image

also remove Selenium2Driver::withSyn() call as completely useless for dragging, the current impl. of Selenium2Driver::dragTo() does not use it

mvorisek avatar Oct 17 '22 11:10 mvorisek

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.64%. Comparing base (a3a5370) to head (afa138b).

:exclamation: Current head afa138b differs from pull request most recent head 663bfb2. Consider uploading reports for the commit 663bfb2 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #359      +/-   ##
============================================
+ Coverage     90.19%   90.64%   +0.45%     
+ Complexity      168      151      -17     
============================================
  Files             1        1              
  Lines           469      449      -20     
============================================
- Hits            423      407      -16     
+ Misses           46       42       -4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 17 '22 11:10 codecov[bot]

is this something that could be covered by a test in the mink driver testsuite ?

stof avatar Oct 17 '22 12:10 stof

is this something that could be covered by a test in the mink driver testsuite ?

probably by hiding the dragged element on dragstart event, but not sure if it is worth doing so, I would call this an implementation detail

mvorisek avatar Oct 17 '22 12:10 mvorisek

Well, if we don't have a test covering it, we risk regressing on that case. And if this is necessary to be compatible with the behavior of the draggable library of Shopify, it means there is a real-world use case for that, not just an implementation detail.

stof avatar Oct 17 '22 13:10 stof

if this will imply the fix will be merged then, I can code the test

probably by hiding the dragged element on dragstart event

simply like this or use native https://github.com/Shopify/draggable lib? (about 100KB)

mvorisek avatar Oct 17 '22 13:10 mvorisek

if we can do it with a simple implementation, it will be better for the driver testsuite IMO.

and yes, once we have tests for it, I would happily accept that patch.

stof avatar Oct 17 '22 13:10 stof

@stof please merge, tested in https://github.com/minkphp/driver-testsuite/pull/59

I will then address https://github.com/minkphp/driver-testsuite/pull/59#issuecomment-1288109277 and https://github.com/minkphp/MinkSelenium2Driver/pull/354

mvorisek avatar Oct 23 '22 13:10 mvorisek

How to skip the Behat\Mink\Tests\Driver\Js\JavascriptTest::testDragDropOntoHiddenItself test on Selenium 2? Or any idea how to fix the driver for Selenium 2?

mvorisek avatar Apr 01 '24 10:04 mvorisek

@mvorisek , Test skipping can be done in the \Behat\Mink\Tests\Driver\Selenium2Config::skipMessage method.

The only purpose of the test you've mentioned (added by you) was to confirm, that code changes from this PR (added by you) will continue to work as expected.

Then, why do you need that test to be skipped?

aik099 avatar Apr 01 '24 16:04 aik099

In Selenium 3 (and with regular mouser/keyboard) the dragging works. In Selenium 2, it seems it does not, IDK why. Help welcomed. I did some experiments with Selenium 2 and it seems the dragging is not emulated well enough.

Please advise what to do and how to detect Selenium 2. Or how to fix Selenium 2 of course if you have an idea.

mvorisek avatar Apr 01 '24 16:04 mvorisek

I've checked on Selenium 2 + Chrome and it works, but Selenium 2 + Firefox doesn't. Visually it looks like once the element is clicked without releasing a mouse button (to perform drag) it disappears somewhere and never drops back.

Maybe it is a bug in Selenium or geckodriver itself.

aik099 avatar Apr 01 '24 18:04 aik099

I've checked with different Firefox versions on Selenium 2 and :

  • on Firefox 47 it doesn't work (used in GitHub Actions)
  • on Firefox 92 it does work

I wish we could use the more recent browser versions on GitHub Actions. Maybe used docker image page can help in detecting what docker image version should get us desired Selenium Server + Firefox version: https://hub.docker.com/r/selenium/standalone-firefox .

aik099 avatar Apr 03 '24 07:04 aik099

@uuf6429 , do you know what tag of the selenium-firefox Dockerimage needs to be used to get the Selenium 2 and modern Firefox version?

Tests for this PR are failing only because of outdated Firefox version usage in the Selenium Dockerimage.

The same test failure also occurs on the https://github.com/minkphp/webdriver-classic-driver/pull/27 .

aik099 avatar Apr 07 '24 16:04 aik099

@aik099 selenium/standalone-firefox:2 typically means "the latest selenium 2 with the latest firefox available at that time". In other words, I don't think they are building images for with selenium 2 and updated firefox since they stopped maintaining selenium 2.

That being said, we could probably reverse engineer it (the docker layers are publicly readable) to have an up-to-date firefox.

uuf6429 avatar Apr 07 '24 18:04 uuf6429

@aik099 selenium/standalone-firefox:2 typically means "the latest selenium 2 with the latest firefox available at that time". In other words, I don't think they are building images for with selenium 2 and updated firefox since they stopped maintaining selenium 2.

That being said, we could probably reverse engineer it (the docker layers are publicly readable) to have an up-to-date firefox.

If that can be done, then both Selenium-based drivers would benefit from this. I've created a #391 about this.

aik099 avatar Apr 08 '24 07:04 aik099