Php-webdriver: dragAndDropBy uses absolute position instead of offset in 1.8.0

Created on 11 Feb 2020  路  5Comments  路  Source: php-webdriver/php-webdriver

What are you trying to achieve? (Expected behavior)

I am using php-webdriver for unit-testing, in which one test involves dragging and dropping a specific element. In 1.7.1, this was written as

        $actions = new WebDriverActions($this->driver);
        $actions->dragAndDropBy(
            $this->element,
            0,
            -50
        )->perform();

and it worked perfectly.

What do you get instead? (Actual behavior)

After the auto-update of composer to 1.8.0, the test threw a MoveTargetOutOfBoundsException.

Some debugging attempts did not solve the problem. In 1.7.1, the HttpCommandExecutor::execute got the following inputs:

$raw => {"method":"POST","url":"\/session\/:sessionId\/moveto"}
$http_method => "POST",
$url => "\/session\/3fcbbbc0446b4c1bbb7cae8e0424c3a5\/moveto",
$params => {"xoffset":0,"yoffset":50},

In 1.8.0 there seemed to be at least 2 relevant executed commands:
1:

$http_options => {"url":"\/session\/:sessionId\/actions","method":"POST"},
$http_mehtod => "POST"
$url => "\/session\/c38e68185246f7f29fe206c62d2a6c19\/actions"
$params => {"actions":[{"type":"pointer","id":"mouse","parameters":{"pointerType":"mouse"},"actions":[{"type":"pointerMove","duration":0,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"b72b8ae5-b44c-44be-8b27-d7fca391e562"}},{"type":"pointerDown","duration":0,"button":0}]}]}

2:

$http_options => {"url":"\/session\/:sessionId\/actions","method":"POST"}
$http_method => "POST"
$url => "\/session\/c38e68185246f7f29fe206c62d2a6c19\/actions"
$params => {"actions":[{"type":"pointer","id":"mouse","parameters":{"pointerType":"mouse"},"actions":[{"type":"pointerMove","duration":0,"x":0,"y":-50}]}]}]

The second execute gives the error. Maybe the problem is solved when this is also given an origin? I'm not sure.

How could the issue be reproduced? (Steps to reproduce)


The Selenium server is initialised by exec vendor/bin/selenium-server-standalone within a proc_open, and the webdriver by RemoteWebDriver::create(localhost:4444/wd/hub, $caps)

The relevant HTML is

<div class="list-group overige_stukjes" id="overig">
    <a class="list-group-item stukje" href="/mails/bewerk/3/7" data-id="7" data-categorie="overig" data-volgorde="1">
    <em>Naamloos stukje</em>
    </a>
    <a class="list-group-item stukje" href="/mails/bewerk/3/8" data-id="8" data-categorie="overig" data-volgorde="2" style="">
    <em>Naamloos stukje</em>
    </a>
</div>

Here I try to move the Naamloos stukjes up or down. Maybe the following JavaScript is also relevant (Using JQuery):

 // Drag/drop van mailstukjes
        $('#overig').sortable({
            nested: false,
            group: 'overige_stukjes',
            containerSelector: '.overige_stukjes',
            itemSelector: 'a.stukje',
            placeholder: '<a class="list-group-item huidig-stukje"> </a>',
            onDrop: ondrop,
        });

Again, the php trying to do the drop-and-drag looks like this:

        $actions = new WebDriverActions($this->driver);
        $actions->dragAndDropBy(
            $this->element,
            0,
            -50
        )->perform();

Details

  • Php-webdriver version: 1.8.0
  • PHP version: 7.2.24
  • Selenium server version: Selenium Standalone v.3.141.59 (I guess?)
  • Operating system: Bionic beaver
  • Browser used + version: chromedriver 79.0.3945.130
bug

All 5 comments

Someone also reported this for Dusk: https://github.com/laravel/dusk/issues/732#issuecomment-584580045

+1
Having the same issue on laravel/dusk because the underlying functionality in webdriver/php-webdriver changed in 1.8.0. Following the issue.

The fix should be prepared in #764 .

I added some missing drag and drop tests (which uses jQuery sortable), but could someone confirm it now works again for them? @wgevaert @ahtinurme

The unit-test works for me now (after cloning your fork into the vendor dir), thanks a lot!

Version 1.8.1 has just been released :rocket:

Was this page helpful?
0 / 5 - 0 ratings