appium-gesture Password Implementation

Source: Internet
Author: User
Tags appium

1. The range of the red area is: [66,575][1014,1523], because this block is a whole block, so the data of each point cannot be used, so you can only use the Lockpatternview object to get the coordinate value of the upper left corner

2. Principle, divides nine gongge into 6 pieces, the top left corner coordinates is [66,575], we assume "startx,starty", the height of the whole area is the width of the space, then Xstep = WIDTH/6, Ystep = height /6. where Xstep and Ystep respectively represent the width and height of each block after being divided into 6 blocks.

Based on the above variables, we can deduce:

The coordinates of the first point are "startx+xstep, Starty + ystep"; The coordinates of the second point are "startx+3*xstep, Starty + ystep"; The coordinates of the third point are "Startx+5*xstep,starty + ystep 】

The coordinates of the fourth point are "startx+xstep, Starty + 3*ystep", and the coordinates of 9 Gongge 9 points can be obtained by analogy;

3. The code is as follows: This is done here is a gesture code of L from the middle starting point.

1      Public voidSetlockpattern (String ID)throwsException {2         if(Driver.getpagesource (). Contains ("Set gesture password")) {//detects if a gesture password is present3list<androidelement> element = driver.findelements (By.xpath (Constant.xpath_view + "[Contains (@resource-id, '" + ID + "')]"));4Thread.Sleep (1000);//wait 1 seconds before touching5Androidelement gelemt = element.get (0);//get to this element to take it as an object to do6             intStartX = Gelemt.getlocation (). GetX ();//gets the starting point x coordinate of the element7             intStarty = Gelemt.getlocation (). GetY ();//gets the starting point y coordinate of the element8             intHeight = gelemt.getsize (). GetHeight ();//gets the height of the element9             intwidth = gelemt.getsize (). GetWidth ();//gets the width of the elementTen             intXStep = WIDTH/6;//Divide the width into 6 parts One             intYstep = HEIGHT/6;//Divide the height into 6 parts A             intBeginX = StartX + 3*xstep;//calculate touch start point x coordinate -             intBeginY = Starty + ystep;//calculate the touch point y coordinate -Touchaction TA =NewTouchaction (driver);//Initialize Touchaction the    -             //ta.press (BeginX, BeginY). Waitaction (0, MoveTo + beginy). 2*ystep (0, waitaction + moveTo ). Waitaction. MoveTo ((BeginX + 2*xstep), BeginY + 4*ystep). Waitaction (). perform (); -Ta.press (BeginX, BeginY). MoveTo (0, BeginY + 2*ystep). MoveTo (0, BeginY + 4*ystep). MoveTo (BeginX + 2*xstep, BeginY +ystep). Release (). perform (); -Sleep (2000); +Ta.press (BeginX, BeginY). MoveTo (0, BeginY + 2*ystep). MoveTo (0, BeginY + 4*ystep). MoveTo (BeginX + 2*xstep, BeginY +ystep). Release (). perform (); -Logger.info ("Gesture Password Setup Complete"); +  A         } at}

1) ta.press (Beginx,beginy), starting from [beginx,beginy] coordinates, moveTo "x, y" to move [x, y] relative to [beginx,beginy] coordinates , that is, the final coordinate is " Beginx+x, Beginy+y ";

2) waitaction (int ms), refers to the number of milliseconds to stay;

3) The release () method, which refers to releasing the current gesture;

4) Perform () method, display the whole gesture chain;

5) General set gesture password is to be two times to complete the setup operation;

appium-gesture Password Implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.