mirror of
https://github.com/appium/appium.git
synced 2026-10-29 12:41:58 +08:00
[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
This commit is contained in:
committed by
Srinivasan Sekar
parent
f40bfb8ebe
commit
375dfd2a4a
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user