Appium-based mobile automation testing, the password keypad does not recognize the problem

Source: Internet
Author: User
Tags appium

Based on Appium to do automated testing, the app password keyboard does not recognize the problem of solving ideas

The solution to this problem is as follows:


  1. For iOS unordered keyboard : First, the password keyboard for iOS is recognizable, but the password keyboard is generally unordered. For this situation, the idea is to use Macaca or appium-inspector to obtain information about each key. First, define a data dictionary key_num={} and save the XPath for each key into the dictionary. In this way the Key_num is key_num[0]= "The XPath path of the first key", key_num[1]= "the XPath path of the second key", and so on, the XPath path of the entire keyboard is logged. The name value of the element can then be obtained through the value of XPath, which is the number of the key, with the name value: Object. Get_attribute ("name"). Then, define another dictionary, keys_num={}, to hold the corresponding XPath and corresponding number for each key. For example: The first key is "6", write keys_num[6]= "First key XPath", the second key is "4", keys_num[4]= "the second key of the XPath", and so on, record the entire keyboard number and the corresponding XPath. So when entering the password, as long as the password is traversed, for example: the password is "666888", then the first value of the password is 6, we take the value of keys_num[6] can be obtained to the "number 6" XPath, in through Get_element_by_xpath (" The number 6 XPath ") method can be obtained to the element, and then the element. Click () to click, you can enter this value.


  2. For Android unordered and unrecognized keyboard : Android's password keyboard is generally unordered and unrecognized. We need to use the technology of OCR, we should not be nervous, you can find the relevant OCR class library, such as the Python script can find the Python library, the use is very simple. Below is how to solve the password keyboard recognition problem. First, using ADB to intercept the password keyboard interface, the keyboard interface through OCR to identify the order of the keyboard numbers, such as: the numeric order of the keyboard is "9638527410", then we can know that the first row of the keyboard popup is "963", the first key is "9", the second key is "6" And so on However, some people will ask "since we do not recognize the keyboard, then how to get keyboard information?" ", yes, we can only get the keyboard number by OCR, but we can't get the key information. So how do you click it? Next, we turn on the "pointer position" function of andorid and calculate the position of each key on the screen (calculated by a percentage of the way: The key is in the relative position of the screen). Then define the dictionary key_num_x={},key_num_y={} to record the coordinates of the key, for example, the value of the first key is 6 then write key_num_x[6]= "x-coordinate of the first key", key_num_y[6]= "the y-coordinate of the first key". And so on All key information is logged. So when entering the password, as long as the password is traversed, for example: the password is "666888", then the first value of the password is 6, we take key_num_x[6] and key_num_y[6] value, in through the Driver.tap ([{x-coordinate, y-coordinate}]) This method can be clicked.

Appium-based mobile automation testing, the password keypad does not recognize the problem

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.