public class SwipeDevice {
AndroidDriver driver;
@BeforeTest
public void SetUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "CELZSSMJUOJBPV99");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", "com.android.settings.Settings");
try
{
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
catch(Exception e)
{
e.printStackTrace();
}
}
@Test(priority=0)
public void testCal() throws Exception
{
String str="Security";
// driver.scrollTo(str);
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\""+str+"\").instance(0))").click();
}
@Test(priority=1)
public void Sum() throws InterruptedException {
// android.widget.TextView
driver.findElement(By.xpath("//android.widget.TextView[contains(@resource-id,'android:id/title') and @text='Screen lock']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//android.widget.TextView[contains(@resource-id,'android:id/title') and @text='Pattern']")).click();
Thread.sleep(2000);
}
@Test(priority=2)
public void Sum1() throws InterruptedException {
// android.widget.TextView
// MultiTouchAction mta1 = new MultiTouchAction(driver);
//
// TouchAction d1= swipe(532,270,770,249,2000);
// TouchAction d2= swipe(770,249,535,493,2000);
// TouchAction d3= swipe(535,493,775,492,2000);
// mta1.add(d1).add(d2).add(d3).perform();
driver.swipe(532,270,770,249,2000);
driver.swipe(770,249,535,493,2000);
driver.swipe(535,493,775,492,2000);
Thread.sleep(2000);
// new TouchAction(driver).press(532,270).moveTo(770,249).release().perform();
// new TouchAction(driver).press(532,270).moveTo(770,249).moveTo(535,493).moveTo(775,492).release().perform();
// Thread.sleep(4000);
// new TouchAction(driver).press(532,270).waitAction(2000).moveTo(770,249).waitAction(2000).moveTo(535,493).moveTo(775,492).release().perform();
// Thread.sleep(2000);
//
MultiTouchAction mta = new MultiTouchAction(driver);
TouchAction ta0 = new TouchAction(driver).longPress(532,270).moveTo(770,249).waitAction(1000);
TouchAction ta1 = new TouchAction(driver).longPress(770,249).moveTo(535,493).waitAction(1000);
TouchAction ta2 = new TouchAction(driver).longPress(535,493).moveTo(775,492).waitAction(1000);
mta.add(ta0).add(ta1).add(ta2).perform();
}
@AfterTest
public void End() throws InterruptedException
{
driver.quit();
}
}
Not Able to make “Z” in single stroke…
if anyone has code plz provide me with same