question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DragNDrop fails with null object reference

See original GitHub issue

@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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
saikrishna321commented, Aug 26, 2018

@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));
1reaction
mykola-mokhnachcommented, Aug 24, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android - NullReferenceException on Scroll/Drag-and-Drop ...
The error say that you have a null object reference. Check the object that generate the problem and watch is correctly instantiated. example...
Read more >
Drag n drop fails - Object reference not set to an instance of an ...
An unhandled exception of type 'System.NullReferenceException' occurred in Sandbox.exe Additional information: Object reference not set to an ...
Read more >
Drag from External Listbox (Null Object Reference Exception) On ...
I'm trying to drag from an external list box to the schedule view control, but i'm getting a "Object reference not set to...
Read more >
Drag-drop operations cause the "Object reference not set to ...
I can't get node drag/drop to work. Steps to Reproduce: The attached project recreates the error. The test data table is running in ......
Read more >
Error Attempt to De-Reference A Null Object For a Results ...
I am not sure, but it looks like your error is in line results.outputMember.add(curSobject); . If that is the case, then the solution...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found