CN114238142A - Automatic mobile terminal ui testing method based on apium + python - Google Patents

Automatic mobile terminal ui testing method based on apium + python Download PDF

Info

Publication number
CN114238142A
CN114238142A CN202111599406.2A CN202111599406A CN114238142A CN 114238142 A CN114238142 A CN 114238142A CN 202111599406 A CN202111599406 A CN 202111599406A CN 114238142 A CN114238142 A CN 114238142A
Authority
CN
China
Prior art keywords
python
test
mobile terminal
excel
apium
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111599406.2A
Other languages
Chinese (zh)
Inventor
邓金洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Cric Technology Co ltd
Original Assignee
Sichuan Cric Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Cric Technology Co ltd filed Critical Sichuan Cric Technology Co ltd
Priority to CN202111599406.2A priority Critical patent/CN114238142A/en
Publication of CN114238142A publication Critical patent/CN114238142A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Stored Programmes (AREA)
  • Telephone Function (AREA)

Abstract

The invention discloses an apium + python-based mobile terminal ui automatic testing method, which comprises the following steps of: constructing python engineering, including catalogues: common, excel _ data, result, testcase, runner; encapsulating a mobile terminal ui element searching method, an operation method, an excel data reading method, a screenshot method and a driver for driving apium by using a python related function in a catalog common; a unit test framework unit package test suite acquisition method of python is used in a directory runner; compiling a test case script for the function of the app to be tested in a directory testcase by using a python language; creating excel form management test data and measured ui element information in the catalog excel _ data; and executing the test case, starting a driver to call the appium service to connect the mobile terminal equipment, starting the app and executing specified operation on the app according to the test case. The functional logic and ui interaction automatic test of the mobile terminal can be realized, the code compiling efficiency and the test accuracy are improved, and the labor cost is reduced.

Description

Automatic mobile terminal ui testing method based on apium + python
Technical Field
The invention relates to the technical field of internet, in particular to an apium + python-based automatic mobile terminal ui testing method.
Background
In the prior art, the mobile terminal ui automatic test mainly sends a request execution test instruction to the apium by executing a test script, and each test case needs a large amount of scripts to control a large amount of test data; however, the use case script and the test data are not well managed, so that the code and the data are disordered; therefore, a great deal of modification work can be generated when the function logic and the test data of the use case are changed, scripts and data errors are easily caused, the test accuracy is influenced, and even the scripts can not be executed due to paralysis; and thus the workload increases.
Disclosure of Invention
The invention aims to provide an apium + python-based mobile terminal ui automatic test method, which aims to solve the problems that a large number of test cases and test data need to be executed in the current automatic test, so that errors are easily caused in replacing the test data or modifying the logic of the test cases, and even scripts are paralyzed.
In order to achieve the purpose, the invention adopts the following technical scheme:
an apium + python-based mobile terminal ui automatic testing method comprises the following steps:
constructing python engineering, including catalogues: common, excel _ data, result, testcase, runner;
encapsulating a mobile terminal ui element searching method, an operation method, an excel data reading method, a screenshot method and a driver for driving apium by using a python related function in a catalog common;
a unit test framework unit package test suite acquisition method of python is used in a directory runner;
compiling a test case script for the function of the app to be tested in a directory testcase by using a python language;
creating excel form management test data and measured ui element information in the catalog excel _ data;
and executing the test case, starting a driver to call the appium service to connect the mobile terminal equipment, starting the app and executing specified operation on the app according to the test case.
In some embodiments, the encapsulating, in the directory common, the mobile end ui search, the operation method, the excel data reading method, the screenshot method, and the driver for driving the apium using the correlation function of python includes:
packaging a mobile end ui element searching method and an operation method by using a method in a Webelement related library of python in a catalog common; packaging an excel data reading method by using a related method in an xlrd library of python; encapsulating the screenshot method by using a get _ screen _ as _ file function of python; and encapsulating the driver which is used for configuring the apium service, connecting the mobile equipment and starting the tested application.
In some embodiments, the excel _ data directory manages test data using an excel document; the result directory is used as a storage path of the test report and the screenshot attachment; compiling test cases of the app to be tested by the testcall directory, wherein each test case has a script; and editing the method for acquiring the test suite in the runner directory.
In some embodiments, the method in the WebElement related library of python is used in the catalog common to encapsulate the mobile end ui element search method and operation method, including searching, clicking, inputting and dragging elements according to the element id, name, xpath and the like; and parameterizing the element unique identification during packaging.
In some embodiments, the method encapsulates excel data reading methods using the associated methods in the xlrd library of python; the method comprises the steps of sequentially reading all data of a specified form and reading a certain line of data in the specified form as required.
In some embodiments, the method for encapsulating screenshot by using get _ screenshot _ as _ file function of python includes: when a problem occurs in the test process, the automatic screenshot is stored and stored in a result directory when the case cannot pass, the picture naming rule is "% Y-% M-% d-% H-% M-% S + test case name", the picture naming rule is used for immediately storing the screenshot after finding the bug in the automatic test process, and the bug is located at the later stage according to the time and the test case name.
In some embodiments, the package configures a driver of the appium service to connect to the mobile device and launch the application under test, including that the driver connects to the corresponding mobile device through the name and version of the mobile device according to the address and port number of the appium server and launches the app under test through the package name and Activity of the app under test on the mobile device.
In some embodiments, a unit test framework unit of python is used for obtaining a test case according to a case storage path and a case name to form a test suite; and each test case acquires the mobile terminal ui element information and the test data stored in the excel by calling the excel data reading method.
In some embodiments, the search type of the mobile end ui element information obtained by calling the element operation method searches for the element, and then automatically performs an operation on the relevant element according to the operation type.
The mobile terminal ui automatic testing method based on appium + python disclosed by the application has the possible advantages that the method is not limited to:
according to the method, test data and element information are managed through excel documents, a test case scene and an operation element method are packaged by python, the python packaging appium service is connected with mobile equipment and starts app, then the operation type of a specified element is automatically selected through the test data and the element information stored in excel, and the test case scene test is completed. A set of code and data separation is formed, so that only modifying codes for logic change can not affect test data, and only modifying data for test data change can not affect codes; and the code can be reused. The code compiling efficiency and the test accuracy are improved, and the workload is reduced.
Drawings
FIG. 1 is a flow chart of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail with reference to the following embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
On the contrary, this application is intended to cover any alternatives, modifications, equivalents, and alternatives that may be included within the spirit and scope of the application as defined by the appended claims. Furthermore, in the following detailed description of the present application, certain specific details are set forth in order to provide a better understanding of the present application. It will be apparent to one skilled in the art that the present application may be practiced without these specific details.
An automatic testing method for the mobile terminal ui based on apium + python according to the embodiment of the application will be described in detail below. It is to be noted that the following examples are only for explaining the present application and do not constitute a limitation to the present application.
As shown in fig. 1, an apium + python-based mobile terminal ui automated testing method includes the following steps:
the method comprises the following steps: and newly building a python project, comprising the following catalogues: common, excel _ data, result, testcase, runner.
Step two: packaging a mobile end ui element searching method and an operation method by using methods in a relevant library such as WebElement of python in a catalog common; packaging an excel data reading method by using a related method in an xlrd library of python; encapsulating the screenshot method by using a get _ screen _ as _ file function of python; and encapsulating the driver which is used for configuring the apium service, connecting the mobile equipment and starting the tested application.
Step three: the unit test framework unit package test suite acquisition method of python is used in the directory runner.
Step four: and writing a test case script for the tested mobile terminal ui in a directory testcase by using a python language.
Step five: and creating excel form management test data and ui element information of the tested mobile terminal in the table of contents excel _ data.
In order to better realize the invention, the further technical scheme is as follows:
according to one embodiment of the invention, the method for searching the ui element of the mobile terminal packaged in the common directory in the step one, the operation method, the excel reading method, the screenshot method and the driver for starting the apple are adopted; managing test data by adopting an excel document in an excel _ data directory; the result directory is used as a storage path of the test report and the screenshot attachment; and compiling test cases of the tested app by the testface directory, wherein each case has one script. And editing the method for acquiring the test suite in the runner directory.
The further technical scheme is as follows: and in the second step, the searched elements and the operation elements are secondarily packaged according to the requirements of the searched elements and the operation elements by calling methods in related libraries such as WebElement of python and the like, and the searched, clicked, input and dragged elements are included according to the id, the name, the xpath and the like of the elements. When packaging, the element unique identification (id, name, xpath and the like) is parameterized.
The further technical scheme is as follows: and step two, packaging an excel data reading method by calling a related method in an xlrd library of python, wherein the method comprises the steps of reading all data of a specified form in sequence, and reading a certain line of data in the specified form as required (the excel storage path, the shell name and the form line number required to be read are taken as parameters to be transmitted).
The further technical scheme is as follows: and step two, a get _ screen _ as _ file function encapsulation screenshot method of python is called, so that automatic screenshot is stored and stored in a result directory when a problem encountered in the test process cannot pass a case, the picture naming rule is "% Y-% M-% d-% H-% M-% S + test case name", the picture naming rule is used for immediately storing the screenshot after finding the bug in the automatic test process, and the bug can be located according to the time and the test case name in the later period.
The further technical scheme is as follows: in the second step, the driver is used for connecting the corresponding mobile device through the name and version of the mobile device according to the address and port number of the appium server and starting the app to be tested through the name and Activity of the app package to be tested on the mobile device.
The further technical scheme is as follows: and in the third step, the unit test framework unit test of python is used for obtaining the test cases in the fourth step according to the case storage path and the case name to form a test suite.
The further technical scheme is as follows: step four, each test case acquires the mobile terminal ui element information and the test data stored in the excel in step five by calling the excel data reading method in step two;
the further technical scheme is as follows: and calling the element operation method in the step two to search the elements according to the search types (such as by _ xpath, by _ name and the like) of the element information of the mobile terminal ui acquired in the scheme, and then automatically executing operation on the related elements according to the operation types (such as send _ keys, click and the like).
The further technical scheme is as follows: in the scheme, when the operation of the element is wrong, the screenshot method in the step two is called to store the screenshot of the current operation element page, so that the test problem can be conveniently tracked and searched in the later period;
the further technical scheme is as follows: building an app automatic test framework of appium + python is completed in the first step to the fifth step; when the project function is changed, the modification can be completed by changing the test case scene in the fourth step; when the test data is changed, the modification can be completed by modifying the test data in excel in the step five.
According to the method, test data and element information are managed through excel documents, a python packaging test case scene and an operation element method are adopted, a python packaging appium service is connected with mobile equipment and starts an app, then the operation type of a specified element is automatically selected through the test data and the element information stored in the excel, and test case scene testing is completed. A set of code and data separation is formed, so that only modifying codes for logic change can not affect test data, and only modifying data for test data change can not affect codes; and the code can be reused. The code compiling efficiency and the test accuracy are improved, and the workload is reduced.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (9)

1. An apium + python-based mobile terminal ui automatic testing method is characterized by comprising the following steps:
constructing python engineering, including catalogues: common, excel _ data, result, testcase, runner;
encapsulating a mobile terminal ui element searching method, an operation method, an excel data reading method, a screenshot method and a driver for driving apium by using a python related function in a catalog common;
a unit test framework unit package test suite acquisition method of python is used in a directory runner;
compiling a test case script for the function of the app to be tested in a directory testcase by using a python language;
creating excel form management test data and measured ui element information in the catalog excel _ data;
and executing the test case, starting a driver to call the appium service to connect the mobile terminal equipment, starting the app and executing specified operation on the app according to the test case.
2. The method as claimed in claim 1, wherein the encapsulating, in the directory common, the correlation function of python for the mobile end ui lookup, the operation method, the excel data reading method, the screenshot method, and the driver for driving apium, includes:
packaging a mobile end ui element searching method and an operation method by using a method in a Webelement related library of python in a catalog common; packaging an excel data reading method by using a related method in an xlrd library of python; encapsulating the screenshot method by using a get _ screen _ as _ file function of python; and encapsulating the driver which is used for configuring the apium service, connecting the mobile equipment and starting the tested application.
3. The method for automatically testing the ui of the mobile terminal based on the apium + python as claimed in claim 1, wherein an excel document is adopted in an excel _ data directory to manage test data; the result directory is used as a storage path of the test report and the screenshot attachment; compiling test cases of the app to be tested by the testcall directory, wherein each test case has a script; and editing the method for acquiring the test suite in the runner directory.
4. The method for automatically testing the ui of the mobile terminal based on the apium + python as claimed in claim 2, wherein the method in the Webelement correlation library of python is used in the catalog common to package the element search method and the operation method of the ui of the mobile terminal, comprising searching, clicking, inputting and dragging the elements according to the element id, name, xpath and the like; and parameterizing the element unique identification during packaging.
5. The method for automatically testing the ui of the mobile terminal based on the apium + python as claimed in claim 2, wherein the excel data reading method is packaged by using a related method in an xlrd library of python; the method comprises the steps of sequentially reading all data of a specified form and reading a certain line of data in the specified form as required.
6. The method for automatically testing the ui of the mobile terminal based on the apium + python as claimed in claim 2, wherein the method for encapsulating the screenshot by using the get _ screen _ as _ file function of python comprises: when a problem occurs in the test process, the automatic screenshot is stored and stored in a result directory when the case cannot pass, the picture naming rule is "% Y-% M-% d-% H-% M-% S + test case name", the picture naming rule is used for immediately storing the screenshot after finding the bug in the automatic test process, and the bug is located at the later stage according to the time and the test case name.
7. The method as claimed in claim 2, wherein the packaging configures a driver of the apium service for connecting to the mobile device and starting the application to be tested, and the driver is used for connecting to the corresponding mobile device through the mobile device name and version according to the address and port number of the apium server and starting the app to be tested through the package name and Activity of the app to be tested on the mobile device.
8. The method for automatically testing the ui of the mobile terminal based on the apium + python as claimed in claim 1, wherein a unit test framework unit test of python is used for obtaining test cases according to case storage paths and case names to form a test suite; and each test case acquires the mobile terminal ui element information and the test data stored in the excel by calling the excel data reading method.
9. The method for automatically testing the ui of the mobile terminal based on the apium + python as claimed in claim 1, wherein the element operation method is invoked to obtain the search type search element of the element information of the mobile terminal ui, and then the operation is automatically performed on the relevant element according to the operation type.
CN202111599406.2A 2021-12-24 2021-12-24 Automatic mobile terminal ui testing method based on apium + python Pending CN114238142A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111599406.2A CN114238142A (en) 2021-12-24 2021-12-24 Automatic mobile terminal ui testing method based on apium + python

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111599406.2A CN114238142A (en) 2021-12-24 2021-12-24 Automatic mobile terminal ui testing method based on apium + python

Publications (1)

Publication Number Publication Date
CN114238142A true CN114238142A (en) 2022-03-25

Family

ID=80762675

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111599406.2A Pending CN114238142A (en) 2021-12-24 2021-12-24 Automatic mobile terminal ui testing method based on apium + python

Country Status (1)

Country Link
CN (1) CN114238142A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114880239A (en) * 2022-05-31 2022-08-09 成都秦川物联网科技股份有限公司 Interface automation testing framework and method based on data driving

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190179732A1 (en) * 2017-12-08 2019-06-13 Cognizant Technology Solutions India Pvt. Ltd. System and method for automatically generating software testing scripts from test cases
CN111913889A (en) * 2020-09-11 2020-11-10 中移(杭州)信息技术有限公司 Test system building method and test system
WO2020233331A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 User interface automated testing method and apparatus, and computer-readable storage medium
CN112100080A (en) * 2020-11-03 2020-12-18 广州市玄武无线科技股份有限公司 Control testing method and device, terminal equipment and computer readable storage medium
CN112256569A (en) * 2020-10-16 2021-01-22 四川长虹电器股份有限公司 Automatic testing method for simultaneous operation of multiple mobile phones based on apium + python
CN112286779A (en) * 2019-07-23 2021-01-29 腾讯科技(深圳)有限公司 Test task processing method and device, storage medium and computer equipment
CN113672519A (en) * 2021-09-08 2021-11-19 湖南惠农科技有限公司 UI automation test method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190179732A1 (en) * 2017-12-08 2019-06-13 Cognizant Technology Solutions India Pvt. Ltd. System and method for automatically generating software testing scripts from test cases
WO2020233331A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 User interface automated testing method and apparatus, and computer-readable storage medium
CN112286779A (en) * 2019-07-23 2021-01-29 腾讯科技(深圳)有限公司 Test task processing method and device, storage medium and computer equipment
CN111913889A (en) * 2020-09-11 2020-11-10 中移(杭州)信息技术有限公司 Test system building method and test system
CN112256569A (en) * 2020-10-16 2021-01-22 四川长虹电器股份有限公司 Automatic testing method for simultaneous operation of multiple mobile phones based on apium + python
CN112100080A (en) * 2020-11-03 2020-12-18 广州市玄武无线科技股份有限公司 Control testing method and device, terminal equipment and computer readable storage medium
CN113672519A (en) * 2021-09-08 2021-11-19 湖南惠农科技有限公司 UI automation test method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114880239A (en) * 2022-05-31 2022-08-09 成都秦川物联网科技股份有限公司 Interface automation testing framework and method based on data driving
CN114880239B (en) * 2022-05-31 2024-05-24 成都秦川物联网科技股份有限公司 Data-driven-based interface automation test framework and method

Similar Documents

Publication Publication Date Title
CN107908541B (en) Interface testing method and device, computer equipment and storage medium
CN108845940B (en) Enterprise-level information system automatic function testing method and system
CN112882700B (en) IOS application program construction method and device, electronic equipment and storage medium
CN112506807B (en) Automatic test system for interface serving multiple systems
CN108628751A (en) A kind of useless dependence item detection method and device
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CN112463256A (en) Method, system, electronic device and storage medium for determining configuration file
CN106933642B (en) Application program processing method and processing device
CN106776266B (en) Configuration method of test tool and terminal equipment
CN111913889A (en) Test system building method and test system
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN114138281A (en) Compiling method, device, equipment and medium of software engineering
CN112241370A (en) Verification method, system and device for API (application program interface) interface class
CN112052037A (en) Application software development method, device, equipment and medium
CN114238142A (en) Automatic mobile terminal ui testing method based on apium + python
CN111488144B (en) Data processing method and device
CN111352631B (en) Interface compatibility detection method and device
US10606569B2 (en) Declarative configuration elements
JP7318704B2 (en) Test equipment, test method and program
CN111581051A (en) System operation log processing method, device, equipment and medium based on web front end
CN116414774A (en) File migration method, device, equipment and storage medium
CN113126998B (en) Incremental source code acquisition method and device, electronic equipment and storage medium
CN114816364A (en) Method, device and application for dynamically generating template file based on Swagger
CN113377468A (en) Script execution method and device, electronic equipment and storage medium
CN115705297A (en) Code call detection method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination