From 375dfd2a4a6784de856e32c349f0381297efc7f3 Mon Sep 17 00:00:00 2001 From: Sai Krishna Date: Tue, 28 Aug 2018 08:05:41 +0100 Subject: [PATCH] [DOC] Updated java-example DragNDrop to use Point API (#11256) * Updated java-example DragNDrop to use Point API https://github.com/appium/appium-espresso-driver/issues/213 * fixed review comments * Changed Point move durations to milliSeconds and set value to >=600ms for second movePoint --- commands-yml/commands/interactions/actions.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/commands-yml/commands/interactions/actions.yml b/commands-yml/commands/interactions/actions.yml index 5f6c09552..6ebae579d 100644 --- a/commands-yml/commands/interactions/actions.yml +++ b/commands-yml/commands/interactions/actions.yml @@ -15,12 +15,17 @@ example_usage: WebElement source = (MobileElement) driver.findElementsByAccessibilityId("SomeAccessibilityID"); WebElement target = (MobileElement) driver.findElementsByAccessibilityId("SomeOtherAccessibilityID"); - Actions actionBuilder = new Actions(driver); - Action dragAndDropAction = actionBuilder.clickAndHold(source) - .moveToElement(target, 1, 1) - .release(target) - .build(); - dragAndDropAction.perform(); + 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.ofMillis(0), + PointerInput.Origin.viewport(), source.x, source.y)); + dragNDrop.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg())); + dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(700), + PointerInput.Origin.viewport(),target.x, target.y)); + dragNDrop.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg())); + driver.perform(Arrays.asList(dragNDrop)); python: | element = driver.find_element_by_accessibility_id("elId")