appium-espresso-driver: DragNDrop fails with null object reference

@dpgraham @mykola-mokhnach

Appium Server: Latest Master Java-Client: 6.1.0

MobileElement dragMe = (MobileElement) new WebDriverWait(driver, 30).until(ExpectedConditions
                .elementToBeClickable(MobileBy.AccessibilityId("dragMe")));
 WebElement source = dragMe;
WebElement target = driver.findElementByAccessibilityId("dropzone");
Actions actionBuilder = new Actions(driver);
Action dragAndDropAction = actionBuilder.clickAndHold(source).moveToElement(target, 1, 1)                .release(target).build();
dragAndDropAction.perform();

Server logs: https://gist.github.com/saikrishna321/e0681990382ccde8d6fbc9635170d063

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (18 by maintainers)

Commits related to this issue

Most upvoted comments

@dpgraham Fixes works well…

        Point source = dragMe.getCenter();
        Point target = driver.findElementByAccessibilityId("dropzone").getCenter();
        PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
        Sequence dragNDrop = new Sequence(finger, 1);
        dragNDrop.addAction(finger.createPointerMove(Duration.ofSeconds(1),
                PointerInput.Origin.viewport(), source.x, source.y));
        dragNDrop.addAction(finger.createPointerDown(PointerInput.MouseButton.MIDDLE.asArg()));
        dragNDrop.addAction(finger.createPointerMove(Duration.ofSeconds(1),
                PointerInput.Origin.viewport(),
                target.x, target.y));
        dragNDrop.addAction(finger.createPointerUp(PointerInput.MouseButton.MIDDLE.asArg()));
        driver.perform(Arrays.asList(dragNDrop));

The chain is for sure not the one, which is supposed to work. Try the approach proposed by @jlipps in https://appiumpro.com/editions/29

@saikrishna321 If you are doing a release at the end of the action chain, try removing it.

Thanks @saikrishna321 I think I should have a fix in shortly.