Appium+robotframework automated testing for iOS apps-6: Solutions for gesture ciphers

Source: Internet
Author: User
Tags appium

Gesture password in many 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 parameter is only the starting point and the end point, if the start point and focus of the gesture password are given directly, the middle point will be ignored, and the consecutive use of two times swipe keyword can be successful occasionally in Android, but not once in iOS, in order to completely solve the problem, I carefully read the Appium documents, finally all found, please see from the official website of Appium as follows:


I know that the problem of gesture password can be solved.

Robotframework is based on Python, so only the Appium Python client is installed.

Since Appiumlibrary does not provide a gesture password keyword, write a library yourself. However, the attempt failed, mainly because the Appium execution requires a lot of context parameters, and how to write the library and appiumlibrary interaction is a problem, perhaps can be solved, but it may be more troublesome.

Change the concept, simply the curve to the National Salvation Bar.

Since the installation of appiumlibrary, and it is open source, directly to modify its source code is not fixed it?

So, go to the Appiumlibrary installed folder, the default will be installed to/library/python/2.7/site-packages/appiumlibrary (Android I use Windows 7 for testing, The default installation path is: C:\Python27\Lib\site-packages\AppiumLibrary\keywords), and then find the _touch.py file in the keywords directory, which is it.

Add a method gesture to the class _touchkeywords for this file, with the following code:

def gesture (self, platform): "" "        gesture The Element" ""        Driver = self._current_application ()               action = Touchaction (Driver)                  if platform = = "IOS":            action.press (x=100, y=500). Wait (ms=500). Move_to (x=600, y=0).         Wait (ms=500). Move_to (X=0, y=500). Wait (ms=500). Release ()          else:            action.press (x=50, y=100). Wait (ms=500 ). Move_to (x=150, y=0). \         Wait (ms=500). Move_to (X=0, y=100). Wait (ms=500). Release ()          Action.perform ()

The parameter platform of this method is used for the incoming platform, the value is iOS or Android, here are two key knowledge points:

The coordinates in the 1.press method are absolute coordinates, and the coordinates in the Move_to method are relative coordinates, specifically the coordinates in the first move_to relative to the coordinates in the press method, and the coordinate in the second Move_to method relative to the coordinates in the first move_to method.

2.wait is a must: I did not use wait at the beginning, the result is that the effect is paddling too fast, directly from the first point to the last store, skimming the middle point, plus wait after the normal. Here MS is expressed as milliseconds, and ms=500 is waiting for 500 milliseconds.

It's easy to use: Gesture iOS in iOS, Android for: Gesture Android

Maybe some people will ask why the coordinate point is dead, not as a parameter to pass in it?

In fact, I started with the coordinates as parameters, a total of three sets of coordinates representing the starting point, the middle point and the endpoint coordinates, but the execution is always error, but also can not find the reason, and then thought that the gesture password is unchanged, do not need to change, simply write hard code, if the coordinate changes, then directly change the file can be Anyway, Python is interpreted as the language, the use of the time will be automatically compiled, but also save the trouble of compiling, is also very convenient.

Tested on both iOS and Android.

The two issues in this article are:

1. How to write a library to provide a gesture password

2. How to pass the coordinates in as parameters

Also ask your friends to share your solutions and welcome the interactive discussion.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Appium+robotframework automated testing for iOS apps-6: Solutions for gesture ciphers

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.