Skip to content

Commit 7530dee

Browse files
committed
Add drag'n'drop test.
1 parent 15fadf2 commit 7530dee

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/java/io/appium/java_client/AndroidGestureTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package io.appium.java_client;
1919

20+
import static org.junit.Assert.*;
2021
import io.appium.java_client.remote.MobileCapabilityType;
2122

2223
import java.io.File;
@@ -25,6 +26,8 @@
2526
import org.junit.After;
2627
import org.junit.Before;
2728
import org.junit.Test;
29+
import org.openqa.selenium.By;
30+
import org.openqa.selenium.WebElement;
2831
import org.openqa.selenium.remote.DesiredCapabilities;
2932

3033
/**
@@ -60,6 +63,25 @@ public void MultiGestureSingleActionTest() throws InterruptedException {
6063
multiTouch.add(action0).perform();
6164
}
6265

66+
@Test
67+
public void dragNDropTest() {
68+
driver.scrollToExact("Views").click();
69+
driver.findElement(MobileBy.AndroidUIAutomator("description(\"Drag and Drop\")")).click();
70+
WebElement actionBarTitle = driver.findElement(By.id("android:id/action_bar_title"));
71+
72+
assertEquals("Wrong title.", "Views/Drag and Drop", actionBarTitle.getText());
73+
WebElement dragDot1 = driver.findElement(By.id("com.example.android.apis:id/drag_dot_1"));
74+
WebElement dragDot3 = driver.findElement(By.id("com.example.android.apis:id/drag_dot_3"));
75+
76+
WebElement dragText = driver.findElement(By.id("com.example.android.apis:id/drag_text"));
77+
assertEquals("Drag text not empty", "", dragText.getText());
78+
79+
TouchAction dragNDrop = new TouchAction(driver).longPress(dragDot1).moveTo(dragDot3).release();
80+
dragNDrop.perform();
81+
82+
assertNotEquals("Drag text empty", "", dragText.getText());
83+
}
84+
6385
@Test
6486
public void TapSingleFingerTest() {
6587
driver.tap(1,100,200,1000);

0 commit comments

Comments
 (0)