Transferred from: http://blog.csdn.net/codekxx/article/details/50577381
Gesture password in many mobile applications will be shipped, gesture password are required to connect at least 4 points, but Appiumlibrary did not provide the corresponding keywords, I try to use the Swipe keyword two times to solve the problem, why use two times? Because the swipe parameters are only the start and end points, if you give the start and end of the gesture password directly, the middle point is ignored.
Mobile QQ gesture password as follows:
Appiumlibrary It is open source, go directly to modify its source code.
So, go to appiumlibrary installed folder, the default installation path is: C:\Python27\Lib\site-packages\AppiumLibrary\keywords), and then to the keywords directory found _ touch.py file, that's it.
Add a method Nine_palace_unlock to the class _touchkeywords for this file, with the following code:
defNine_palace_unlock (self, locator):"""Nine Palace"""Driver=self._current_application () Action=touchaction (driver) Lock_pattern=Driver.find_element_by_xpath (Locator) x= Lock_pattern.location.get ('x') y= Lock_pattern.location.get ('y') Width= Lock_pattern.size.get ('width') Height= Lock_pattern.size.get ('Height') Offset= WIDTH/6P11= Int (x + WIDTH/6), int (y + HEIGHT/6) P12= Int (x + width/2), int (y + HEIGHT/6) P13= Int (x + width-offset), int (y + HEIGHT/6) P21= Int (x + WIDTH/6), int (y + height/2) P22= Int (x + width/2), int (y + height/2) p23= Int (x + width-offset), int (y + height/2) P31= Int (x + WIDTH/6), int (y + height-offset) P32= Int (x + width/2), int (y + height-offset) p33= Int (x + width-offset), int (y + height-offset)Print(P11,P12,P13)Print(p21,p22,p23)Print(p31,p32,p33) P2= P12[0]-P11[0]Print(p2) sleep (3) action.press (x=P11[0],Y=P11[1]). Move_to (x=p2,y=0). Wait (+) move_to (x=p2,y=0). Wait (1000). Move_to (x=-P2,Y=P2). Wait (move_to) (X=-P2,Y=P2). Wait (+). Release (). Wait (+). Perform ()
The code is as follows:
The code is as follows:
Settings * * *Suite setupsuite teardownlibrary appiumlibraryVariables ****** Test Cases * * *Mobile QQ Open application http:Localhost:4723/wd/hub platformname=android platformversion=19 devicename=127.0.0.1:21503 App=${CURDIR}${/}QQ _794.apk apppackage=com.tencent.mobileqq ... appactivity=com.tencent.mobileqq.activity.splashactivity unicodekeyboard=true resetkeyboard=True Wait Until Page Contains Element XPath=//android.widget.linearlayout[@resource-id=\"com.tencent.mobileqq:id/name\ "]/android.view.view[5" #等待手机QQ打开完成Nine Palace Unlock//android.widget.linearlayout[@resource-id=\"com.tencent.mobileqq:id/name\ "]/android.view.view[5][Teardown] Close all applicationsKeywords * * *
Robotframework:app Nine Gongge sliding unlock