Skip to content

Use webdriver JSONprotocol instead of current dragTo implementation #51

Description

@tarjei

I could not get my test to work when using the dragTo implementation in the Selenium2Driver, but this worked:

    private function performDragAndDrop(Element $element, Element $dropZone)
    {
        $session = $this->session->getDriver()->getWebDriverSession();

        //this requires a sequence of steps as follows:
//1st find the source and target/destination elements to use as reference to do the drag and drop
        $from = $session->element('xpath',$element->getXpath());
        $to = $session->element('xpath',$dropZone->getXpath());
//now perform drag and drop
        $session->moveto(array('element' => $from->getID())); //move to source location, using reference to source element
        $session->buttondown(""); //click mouse to start drag, defaults to left mouse button
        $session->moveto(array('element' => $to->getID())); //move to target location, using reference to target element
        $session->buttonup(""); //release mouse to complete drag and drop operation
//it may be worthwhile to encapsulate these steps into a function called draganddrop($src,$target), etc.
    }

Most of the code is just a cut and paste from an example I found in a comment on the internet(I cannot remember where), but it is fairly straight forward.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions