Draw security pattern on Android view

Hi ,
I’ve a following problem :

The control is view , it has a “dots” on it (generated during the run time).
I need to draw a security pattern …

Is it possible to find the view element, and somehow to click “on it” by given location ?

Thanks !

You need to draw a pattern using Action classes. Below is the function which works for me

obj1= Appium::TouchAction.new
obj1.press(:x => 180,:y => 470).move_to(:x => 180,:y => 795).move_to(:x => 590,:y => 795).release.perform

2 Likes

@Shailendra_Jain thanks for the answer , I’m going to try it now,

In general , your solution is for ruby client ?
How it might be achieved in java_client ?

TouchAction obj = new TouchAction(driver);
obj.press(180,470).moveTo(180,795).moveTo(590,795).release().perform();

Thanks,
Sudhanva

@sudhanvam thanks , just wanted to post that I found it as well :smile:

Thanks !

The thing is how do you calculate the location of the “dots” you want to draw trough ?

Hi,

Can you please let me know what capabilities(packagename & activity names or apk file) you are using to get rid of unlock screen? Basically my question how you are getting this unlock screen?

Thanks,
Uday

@UD , the unlock screen is the part of the flow , I’m not doing anything special to get it (or maybe I’ve misunderstood your Q ? )

Done , by using :

element.getSize().getHeight() , element.getLocation().getX() , element.getLocation().getY()

The last question is , what if I want to draw a pattern with more than 3 “dots” ? and the decision of the pattern “length” being made dynamically… how I can achieved it ?

Thanks

Hi,

I have tried this but it did not unlock my android phone:

@Test
public void Tc3_Unlock_Pattern() throws Exception {
System.out.print(“TC3:Unlock pattern”);
Runtime.getRuntime().exec(“adb shell input swipe 257 1235 572 1235”);
Thread.sleep(500);
Runtime.getRuntime().exec(“adb shell input swipe 572 1235 260 1564”);
Thread.sleep(500);
Runtime.getRuntime().exec(“adb shell input swipe 260 1564 532 1504”);
Thread.sleep(500);
System.out.print(“TC3:Executed Successfully”);
}

.I even tried this but it did not work:

Integer x_topLeftCorner=257;
Integer y_topLeftCorner=1235;

Integer x_topRightCorner=572;
Integer y_topRightCorner=1235;

Integer x_bottomLeftCorner= 260;
Integer y_bottomLeftCorner=1438;

Integer x_bottomRightCorner=532;
Integer y_bottomRightCorner=1504;

//Use coordinates to draw the security pattern and unlock the screen 
TouchAction obj = new TouchAction(MBase.getDriver()); 
obj.press(x_topLeftCorner,y_topLeftCorner).moveTo(x_topRightCorner,y_topRightCorner).moveTo(x_bottomLeftCor

What exception / error do you get ?

@ramaninaresh - You can use capabilities, where you can directly set the unlockType and unlockKey…

unlockType: [‘pin’, ‘password’, ‘pattern’, ‘fingerprint’]

unlockKey; If you want to draw suppose ‘L’, then it would be 1478 in key section.

Let me know if this doesn’t work.

Appium version - 1.6.4