AndroidDriver<AndroidElement> driver;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Device");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://deepakkadarivel.github.io/DnDWithTouch/");
WebElement first = driver.findElementByXPath("//*[@id=\"object1\"]");
WebElement second = driver.findElementByXPath("//*[@id=\"drop_zone\"]");
/*Actions act=new Actions(driver);
act.dragAndDrop(first, second).build().perform();*/
Actions act = new Actions(driver);
Action dragAndDrop = act.clickAndHold(first).moveToElement(second).release(first).build();
dragAndDrop.perform();
I’m trying to drag and drop on a mobile browser, on a webpage.
I have tried both above methods in code but it always gets stuck at dragging the particular element. No errors, neither in the eclipse console nor cmd. Just ends the test because no command detected. I tried using the TouchAction class using AndroidEelement for the first and second objects but it doesn’t detect the elements at all. Please help.