Drag and drop functionality is a very important functionality and we can easily perform through Appium.
DesiredCapabilities capabilites = new DesiredCapabilities();
capabilites.setCapability("device", "Android");
capabilites.setCapability("deviceName", "GT-7582");
capabilites.setCapability("platformVersion", "4.4.3");
capabilites.setCapability("platformName", "Android");
capabilites.setCapability("appPackage", "com.mobeta.android.demodslv");
capabilites.setCapability("appActivity", "com.mobeta.android.demodslv.Launcher");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilites);
driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
driver.findElements(By.id("com.mobeta.android.demodslv:id/activity_title")).get(0).click();
List element = driver.findElements(By.id("com.mobeta.android.demodslv:id/drag_handle"));
new TouchAction((MobileDriver)driver).longPress(element.get(0)).moveTo(element.get(3)).release().perform();
LongPress() method of TouchAction class perform the drag action on the web-element and then drop moveTo() method performs the drop functionality, release() method is to release the touch action. Perform() method is used to perfom the series of actions.
0 Comment(s)