minkphp / MinkSelenium2Driver

Selenium2 (webdriver) driver for Mink framework
MIT License
507 stars 163 forks source link

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

Closed mvorisek closed 3 weeks ago

mvorisek commented 2 years ago

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

codecov[bot] commented 2 years ago

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 ```diff @@ 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.

stof commented 2 years ago

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

mvorisek commented 2 years ago

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

stof commented 2 years ago

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.

mvorisek commented 2 years ago

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)

stof commented 2 years ago

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.

mvorisek commented 2 years ago

@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 commented 7 months ago

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?

aik099 commented 7 months ago

@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?

mvorisek commented 7 months ago

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.

aik099 commented 7 months ago

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 commented 7 months ago

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

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 commented 7 months ago

@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 .

uuf6429 commented 7 months ago

@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.

aik099 commented 7 months ago

@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 commented 3 weeks ago

Merging, because test from the https://github.com/minkphp/driver-testsuite/pull/59 is already merged. Thanks @mvorisek .