Hi all,
I want to make a password pattern using swipe. But m facing an issue “While marking points its only accepting 3 points at a streach”.
eg:- If i have to make a “Z” i have to take three different lines…
Is there any way so that i can make “Z” at one strech …(like we do in mobile password)…
Below is the code i have done …(With various scenerios in Commented format).
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MultiTouchAction;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
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,1000);
// TouchAction d2= swipe(770,249,535,493,1000);
// TouchAction d3= swipe(535,493,775,492,1000);
// 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).waitAction(2000).moveTo(770,249).waitAction(2000).moveTo(535,493).moveTo(775,492).release().perform();
// Thread.sleep(2000);
//
// TouchAction obj = new TouchAction(driver);
// obj.press(530,253).moveTo(635,248).moveTo(760,246).moveTo(650,369).moveTo(530,280).moveTo(635,480).moveTo(765,492).release().perform();
// Thread.sleep(2000);
// MultiTouchAction mta = new MultiTouchAction(driver);
// TouchAction ta0 = new TouchAction(driver).press(532,270).moveTo(770,249).waitAction(2000).perform();
// TouchAction ta1 = new TouchAction(driver).press(770,249).moveTo(535,493).waitAction(2000);
// TouchAction ta2 = new TouchAction(driver).press(535,493).moveTo(775,492).waitAction(2000);
// mta.add(ta0).add(ta1).add(ta2).perform();
// Thread.sleep(2000);
}
@Test(priority=3)
public void Swipe() throws InterruptedException {
MultiTouchAction mta = new MultiTouchAction(driver);
TouchAction to1= new TouchAction(driver).press(532,270).moveTo(770,249).moveTo(535,493).moveTo(775,492).release().perform();
Thread.sleep(2000);
}
@AfterTest
public void End() throws InterruptedException
{
driver.quit();
}
}