[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN112559311A - Interface adaptation method and device for automatic testing of mobile terminal - Google Patents

Interface adaptation method and device for automatic testing of mobile terminal Download PDF

Info

Publication number
CN112559311A
CN112559311A CN201910853249.XA CN201910853249A CN112559311A CN 112559311 A CN112559311 A CN 112559311A CN 201910853249 A CN201910853249 A CN 201910853249A CN 112559311 A CN112559311 A CN 112559311A
Authority
CN
China
Prior art keywords
class
interface element
screen
interface
element operation
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.)
Granted
Application number
CN201910853249.XA
Other languages
Chinese (zh)
Other versions
CN112559311B (en
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.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information 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 Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN201910853249.XA priority Critical patent/CN112559311B/en
Publication of CN112559311A publication Critical patent/CN112559311A/en
Application granted granted Critical
Publication of CN112559311B publication Critical patent/CN112559311B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Telephone Function (AREA)

Abstract

The invention discloses an interface adaptation method and device for automatic testing of a mobile terminal, and relates to the technical field of computers. One embodiment of the method comprises: defining an abstract element operation class in an operation case, wherein an interface element operation method applied to a mobile terminal is defined; reading a device identifier of the configured mobile device; dynamically instantiating a screen implementation class corresponding to the equipment identifier, wherein the screen implementation class is a subclass of the abstract element operation class; executing the operation case, calling an interface element operation method defined in the abstract element operation class, calling a method realized by a screen realization class corresponding to the equipment identifier in a polymorphic mode, and finishing interface adaptation to the screen of the mobile equipment by using the interface element position set in the screen realization class. The implementation mode can solve the problem that the hard coded font size can not realize the adaptation of the interface layout, so that the screen position does not need to be concerned for carrying out automatic test operation, and the screen adaptation in the automatic test is realized.

Description

Interface adaptation method and device for automatic testing of mobile terminal
Technical Field
The invention relates to the technical field of computers, in particular to an interface adaptation method and device for automatic testing of a mobile terminal.
Background
The existing mobile terminal automation test usually utilizes the attribute of an interface element to carry out positioning operation, cannot position a self-defined component adopting self-drawing, and still adopts the literal quantity of hard coding to specify the position of the interface element. However, the mobile application generally needs to perform adaptation tests and compatibility tests of multiple devices, the positions of interface elements between different devices are different, and the existing hard-coded literal method cannot meet the requirements.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the existing scheme hard coding word size can not meet the adaptation requirement of interface layout.
Disclosure of Invention
In view of this, embodiments of the present invention provide an interface adaptation method and apparatus for a mobile terminal automation test, which can solve the problem that the hard coded font size cannot be adapted to the interface layout, so that the screen position does not need to be concerned to perform an automation test operation, and screen adaptation in the automation test is implemented.
To achieve the above object, according to an aspect of the embodiments of the present invention, an interface adaptation method for automated testing of a mobile terminal is provided.
An interface adaptation method for automated testing of a mobile terminal comprises the following steps: defining an abstract element operation class in an operation case, wherein an interface element operation method applied to a mobile terminal is defined in the abstract element operation class; reading a device identifier of the configured mobile device; dynamically instantiating a screen implementation class corresponding to the device identifier, wherein the screen implementation class is pre-established and is a subclass of the abstract element operation class; and executing the operation case, wherein when the operation case is executed, the interface element operation method defined in the abstract element operation class is called, and a method realized by a screen implementation class corresponding to the equipment identifier is called in a polymorphic mode, so that the interface adaptation operation of the screen of the mobile equipment is completed by using the interface element position set in the screen implementation class, wherein the method realized by the screen implementation class is the interface element operation method defined in the abstract element operation class.
Optionally, before the step of dynamically instantiating the screen implementation class corresponding to the device identifier, the method includes: obtaining a device identifier of the mobile device by connecting the mobile device or accessing the mobile terminal application through a simulator; establishing a screen implementation class corresponding to the obtained device identifier, and implementing the interface element operation method defined in the abstract element operation class in the screen implementation class, wherein the implementation process comprises the following steps: creating an enumeration type corresponding to a parameter of the interface element operation method defined in the abstract element operation class, wherein the parameter is an interface element naming identifier; in an execution condition corresponding to an enumeration value corresponding to the enumeration type, transmitting the interface element position corresponding to the enumeration value; and executing the interface element operation by using the interface element position.
Optionally, the interface element position corresponding to the enumerated value is obtained by: obtaining diagonal coordinates of the interface element corresponding to the enumeration value by using an interface element positioning tool, and calculating a median coordinate by a median coordinate calculation method according to the obtained diagonal coordinates to serve as the interface element position corresponding to the enumeration value; wherein the median coordinate calculation method is implemented in the abstract element operation class or a screen implementation class corresponding to the device identifier.
Optionally, the diagonal coordinates include coordinates of a first diagonal point and coordinates of a second diagonal point, and the median coordinate calculation method calculates the median coordinate by: and taking an integer part of an average value of the X-axis coordinates of the first diagonal points and the X-axis coordinates of the second diagonal points as an X-axis median coordinate value, and taking an integer part of an average value of the Y-axis coordinates of the first diagonal points and the Y-axis coordinates of the second diagonal points as a Y-axis median coordinate value, thereby obtaining the median coordinate.
Optionally, the interface element operation includes: and simulating click operation and/or gesture operation of the interface element.
According to another aspect of the embodiments of the present invention, an interface adapting apparatus for a mobile terminal automation test is provided.
An interface adapting device for automated testing of a mobile terminal, comprising: the abstract element operation class definition module is used for defining an abstract element operation class in an operation case, and the abstract element operation class defines an interface element operation method applied to the mobile terminal; a device identifier reading module for reading a device identifier of the configured mobile device; a screen implementation class instantiation module, configured to dynamically instantiate a screen implementation class corresponding to the device identifier, where the screen implementation class is pre-established and is a subclass of the abstract element operation class; and the operation case execution module is used for executing the operation case, calling the interface element operation method defined in the abstract element operation class when the operation case is executed, and calling a method realized by a screen realization class corresponding to the equipment identifier in a polymorphic mode, so that the interface adaptation operation of the screen of the mobile equipment is completed by using the interface element position set in the screen realization class, wherein the method realized by the screen realization class is the interface element operation method defined in the abstract element operation class.
Optionally, the system further comprises a screen implementation class creation module, configured to: obtaining a device identifier of the mobile device by connecting the mobile device or accessing the mobile terminal application through a simulator; establishing a screen implementation class corresponding to the obtained device identifier, and implementing the interface element operation method defined in the abstract element operation class in the screen implementation class, wherein the implementation process comprises the following steps: creating an enumeration type corresponding to a parameter of the interface element operation method defined in the abstract element operation class, wherein the parameter is an interface element naming identifier; in an execution condition corresponding to an enumeration value corresponding to the enumeration type, transmitting the interface element position corresponding to the enumeration value; and executing the interface element operation by using the interface element position.
Optionally, the interface element position corresponding to the enumerated value is obtained by: obtaining diagonal coordinates of the interface element corresponding to the enumeration value by using an interface element positioning tool, and calculating a median coordinate by a median coordinate calculation method according to the obtained diagonal coordinates to serve as the interface element position corresponding to the enumeration value; wherein the median coordinate calculation method is implemented in the abstract element operation class or a screen implementation class corresponding to the device identifier.
Optionally, the diagonal coordinates include coordinates of a first diagonal point and coordinates of a second diagonal point, and the median coordinate calculation method calculates the median coordinate by: and taking an integer part of an average value of the X-axis coordinates of the first diagonal points and the X-axis coordinates of the second diagonal points as an X-axis median coordinate value, and taking an integer part of an average value of the Y-axis coordinates of the first diagonal points and the Y-axis coordinates of the second diagonal points as a Y-axis median coordinate value, thereby obtaining the median coordinate.
Optionally, the interface element operation includes: and simulating click operation and/or gesture operation of the interface element.
According to yet another aspect of an embodiment of the present invention, an electronic device is provided.
An electronic device, comprising: one or more processors; the memory is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the interface adaptation method for the mobile terminal automation test provided by the invention.
According to yet another aspect of an embodiment of the present invention, a computer-readable medium is provided.
A computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements the interface adaptation method for mobile-side automation testing provided by the present invention.
One embodiment of the above invention has the following advantages or benefits: defining an abstract element operation class in the operation case, wherein an interface element operation method applied to the mobile terminal is defined in the abstract element operation class; dynamically instantiating a pre-established screen implementation class corresponding to the configured device identifier of the mobile device; and calling an interface element operation method defined in the abstract element operation class during the operation case execution, and calling a method realized by the screen realization class corresponding to the equipment identifier in a polymorphic mode, so that the interface adaptation operation on the screen of the mobile equipment is completed by using the interface element position set in the screen realization class. According to the embodiment of the invention, when the screen coordinate position simulation operation is required in the interface automation test case compiling, the screen position to be operated is separated from the existing interface automation test case code, and the interface automation case is separated from the interface adaptation operation, so that the problem that the interface layout can not be adapted by the hard code word quantity can be solved, the screen position is not required to be concerned for carrying out the automation test operation, and the screen adaptation in the automation test is realized.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram illustrating main steps of an interface adaptation method for automated testing of a mobile terminal according to an embodiment of the present invention;
fig. 2 is a schematic diagram of an interface adaptation execution timing sequence of an automated test at a mobile phone end according to an embodiment of the present invention;
fig. 3 is a schematic diagram of main modules of an interface adapting apparatus for automated testing of a mobile terminal according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As will be appreciated by one skilled in the art, embodiments of the present invention may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
Fig. 1 is a schematic diagram illustrating main steps of an interface adaptation method for automated testing of a mobile terminal according to an embodiment of the present invention.
As shown in fig. 1, the interface adapting method for mobile terminal automation test according to the embodiment of the present invention mainly includes the following steps S101 to S104.
Step S101: and defining an abstract element operation class in the operation case, wherein an interface element operation method applied to the mobile terminal is defined in the abstract element operation class.
The abstract element operation class is a virtual class, i.e., a class that cannot be instantiated. Defining an interface operation method for the application of the mobile terminal in the virtual class, wherein the naming method of the method can be as follows: the method comprises the following steps that the name of a window page of a mobile application + the name of a method of the page operation (a parameter is a named identifier of an operation element), the defined interface operation method is provided for an automatic test script to use, and the definition of a plurality of interface operation methods is provided in a virtual class and is used for describing different operations on different pages. For example, an operation of selecting a pop-up box of a payment method to perform a simulated screen coordinate point operation may define a method as a ordering page _ payment option (payment type).
Step S102: a device identifier of the configured mobile device is read.
A mobile device such as a mobile phone, etc., and taking the mobile phone as an example, the device identifier may be a model of the mobile phone.
The device identifier may be read from the local configuration when the interface for the mobile-side automated test is adapted locally.
When the interface of the mobile-side automation test is adapted by connecting the execution machine (namely, the tested mobile equipment) with the remote server, the equipment identifier can be read from the configuration file of the remote server.
Step S103: dynamically instantiating a screen implementation class corresponding to the device identifier of the configured mobile device, the screen implementation class being pre-established and being a sub-class of the abstract element operation class.
The subclass of the global scope corresponding to the device identifier may be dynamically instantiated using a reflection mechanism. The device identifier configured in this embodiment may be stored in a character string form, and then the screen implementation class corresponding to the device identifier of the mobile device is dynamically instantiated by reflection according to the stored device identifier character string of the mobile device.
Before step S103, the mobile device is connected or the mobile application is accessed through the simulator, so as to obtain the device identifier of the mobile device by using the related command in the existing software development kit, and taking the mobile device as an Android (Android) mobile phone, the device identifier of the Android mobile phone may be obtained through an adb command (a device identifier obtaining command) provided by the Android software development kit. Establishing a screen implementation class corresponding to the obtained device identifier, and implementing an interface element operation method defined in an abstract element operation class in the screen implementation class, wherein the implementation process comprises the following steps: creating an enumeration type corresponding to a parameter of an interface element operation method defined in an abstract element operation class, wherein the parameter is an interface element naming identifier; transmitting interface element positions corresponding to enumeration values in execution conditions corresponding to the enumeration values corresponding to the enumeration types; and executing the interface element operation by using the interface element position.
In establishing a screen implementation class corresponding to the obtained device identifier, since the first character of the device identifier may not be an alphabetical start, but the class name generally requires a character starting with an alphabet, the device identifier may be preceded by a preset alphabetical prefix as the name of the screen implementation class. When the interface element operation method defined in the abstract element operation class is realized in the screen realization class, if all methods in the abstract element operation class are not realized in the screen realization class, an error is reported when the automatic test script is compiled or run, and an automatic implementer can find and modify the problem in time.
The interface element operations may include: and simulating a click operation and/or a gesture operation of the interface element. A click operation such as a single click or the like, and a gesture operation such as a page turn or the like.
The interface element position corresponding to the enumerated value may be obtained by: and obtaining diagonal coordinates of the interface element corresponding to the enumerated value by using an interface element positioning tool in the existing software development kit or a related automatic test tool, and calculating to obtain median coordinates by using a median coordinate calculation method according to the obtained diagonal coordinates to serve as the interface element position corresponding to the enumerated value.
The diagonal coordinates particularly comprise coordinates of a first diagonal point and coordinates of a second diagonal point, for example coordinates of the upper left corner and coordinates of the lower right corner.
The median coordinate calculation method may specifically calculate the median coordinate by: and taking the integer part of the average value of the X-axis coordinates of the first diagonal points and the X-axis coordinates of the second diagonal points as X-axis median coordinate values, and taking the integer part of the average value of the Y-axis coordinates of the first diagonal points and the Y-axis coordinates of the second diagonal points as Y-axis median coordinate values, thereby obtaining the median coordinates through calculation.
The median coordinate calculation method may be implemented in an abstract element operation class or a screen implementation class corresponding to a device identifier of the mobile device.
In one embodiment, the median coordinate calculation method is implemented in the abstract element operation class. A method for calculating the median coordinate according to the interface element coordinate and simulating the median coordinate in operation (such as clicking, gesture and the like) can be packaged in the abstract element operation class. The method includes the step of referencing four coordinate values, namely, the upper left corner coordinate and the lower right corner coordinate corresponding to the interface element to be operated. The method comprises the steps of firstly calculating a median coordinate, namely taking an integer part of an average value of a left upper corner X-axis coordinate and a right lower corner X-axis coordinate as a coordinate of a median point X-axis, taking an integer part of an average value of a left upper corner Y-axis coordinate and a right lower corner Y-axis coordinate as a coordinate of a median point Y-axis, calling a method for simulating corresponding operation and transmitting the obtained median coordinate into the computer.
In another embodiment, the median coordinate calculation method is implemented in a screen implementation class corresponding to a device identifier of the mobile device. A method of calculating median coordinates from the interface element coordinates and simulating the median coordinates for operation (e.g., clicking, gesture, etc.) is defined in the abstract element operation class, and the defined method is embodied by a screen implementation class corresponding to the device identifier of the mobile device.
Step S104: and executing the operation case, calling an interface element operation method defined in the abstract element operation class when the operation case is executed, and calling a method realized by the screen realization class corresponding to the equipment identifier in a polymorphic mode, so that the interface element position set in the screen realization class is utilized to finish the interface adaptation operation of the screen of the mobile equipment.
The method for realizing the screen implementation class is an interface element operation method defined in the abstract element operation class. Polymorphic, i.e., dynamic binding, refers to determining the type of the referenced actual object during execution (rather than during compilation), and invoking its corresponding method according to its actual type.
The abstract element operation class is a parent class of the screen implementation class corresponding to the device identifier, and when the automatic test case executes the screen adaptation operation, an interface element operation method defined in the parent class abstract element operation class is directly called, so that the screen adaptation operation of different devices can be realized.
The embodiment of the invention ensures that a tester only needs to realize the screen implementation class of one mobile phone model when compiling the interface automation test case, is used for debugging the local interface automation test script, can replace the screen implementation classes of other mobile phone models when executing the interface automation case on the executive machine, and interface adapter personnel can realize the adaptation operation of different mobile phone screens according to the corresponding screen implementation classes of the mobile phone models. Therefore, the embodiment of the invention reduces the workload of automatic case maintenance and realizes the screen adaptation of mobile equipment of various models in automatic test.
In addition, because the embodiment of the invention adopts the operation method for packaging the specific interface elements, the operation method is not limited to clicking coordinates, and gesture operation can be realized, for example, the problem of page turning caused by mobile phone screen change, which cannot be solved by the traditional interface adaptation scheme, can be solved well (for example, coordinates on the last line on a large mobile phone screen are displayed, and the corresponding coordinates can be obtained only by scrolling the screen upwards when the screen is changed into a small mobile phone screen).
Fig. 2 is a schematic diagram of an interface adaptation execution timing sequence of an automated test at a mobile phone end according to an embodiment of the present invention.
As shown in fig. 2, according to the interface adaptation process of the mobile phone automation test of this embodiment, at the stage of the process of the initialization case, an abstract element operation class is defined in the operation case, where definitions of a plurality of interface operation methods are provided for describing different operations on different pages. For example, a selection operation interface of payment method can define the following method: a payment method (payment method enumeration class) is selected.
Reading the mobile phone model matched with the interface to be executed from the configuration file, and instantiating a screen implementation class corresponding to the mobile phone model by reflection; the screen implementation class is pre-established, which implements all the methods defined in the abstract element operation class. Taking the selection operation interface of the payment mode as an example, the creation of the enumeration type corresponding to the payment mode includes posting payment, payment to arrive, and payment at monthly balance. The enumeration type in the form parameter corresponds to the enumeration value type in the real parameter. Different enumerated values correspond to different operation element positions, namely, the positions of buttons corresponding to the consignment, the arrival payment and the monthly payment are different. Generally, the same subclass method involves condition judgment execution of a plurality of enumerated values, and based on this example, the logic of condition judgment execution in the screen implementation class is simply expressed as follows:
selecting payment mode (payment mode enumeration type)
{
int x — horizontal position; // three buttons in the same horizontal position, defining a common variable
if (payment method for Chinese character' shen ═ payment method for enumeration type)
{
Click (x, vertical position of posting payment button);
}
if (pay-as-you-go)
{
Click (x, vertical position to pay button);
}
if (payment method for the same parameter)
{
Click (x, vertical position of monthly payment button);
}
}
the coordinates in the condition judgment may be median coordinates corresponding to each enumerated value of the operation element, and the logic executed above omits a method for calculating the median coordinates according to diagonal coordinates, and for the method for calculating the median coordinates, reference may be made to the description of the above embodiment.
And when the operation case is executed, calling an interface element operation method in the abstract element operation class, and calling a method realized by the screen realization class corresponding to the mobile phone model in a polymorphic mode, thereby realizing the interface adaptation of the mobile phone screen of the mobile phone model. The element, i.e. the UI element, is an interface element of the mobile terminal application under test, for example, a payment option button for selecting each payment type in a payment page in the e-commerce app (application).
After the operation case is executed, other cases are continuously executed to complete the whole automatic test process.
The scheme is realized in a polymorphic mode, so that the method for omitting the specific mobile phone screen realization class can be avoided, and if the compiling is not realized, the mistake can be reported. And because the screen coordinates are preset in the specific implementation subclass (namely the screen implementation class) of the mobile phone model, the problems of coordinate recalculation and possible inaccurate coordinate calculation caused by the change of the mobile phone screen are reduced.
Fig. 3 is a schematic diagram of main modules of an interface adapting apparatus for automated testing of a mobile terminal according to an embodiment of the present invention.
As shown in fig. 3, the interface adapting apparatus 300 for automated testing of a mobile terminal according to an embodiment of the present invention mainly includes: abstract element operation class definition module 301, device identifier reading module 302, screen implementation class instantiation module 303 and operation case execution module 304.
The abstract element operation class defining module 301 is configured to define an abstract element operation class in an operation case, where the abstract element operation class defines an interface element operation method applied to the mobile terminal.
A device identifier reading module 302 for reading the device identifier of the configured mobile device.
And a screen implementation class instantiation module 303, configured to dynamically instantiate a screen implementation class corresponding to the device identifier, where the screen implementation class is pre-established and is a subclass of the abstract element operation class.
And the operation case execution module 304 is configured to execute an operation case, and when the operation case is executed, invoke an interface element operation method defined in the abstract element operation class, and invoke a method implemented by a screen implementation class corresponding to the device identifier in a polymorphic manner, so as to complete an interface adaptation operation on the screen of the mobile device by using the interface element position set in the screen implementation class, where the method implemented by the screen implementation class is the interface element operation method defined in the abstract element operation class.
The interface adaptation apparatus 300 may further include a screen implementation class creation module for: accessing a mobile terminal application through a mobile device or a simulator to obtain a device identifier of the mobile device; establishing a screen implementation class corresponding to the obtained device identifier, and implementing an interface element operation method defined in an abstract element operation class in the screen implementation class, wherein the implementation process comprises the following steps: creating an enumeration type corresponding to a parameter of an interface element operation method defined in an abstract element operation class, wherein the parameter is an interface element naming identifier; transmitting interface element positions corresponding to enumeration values in execution conditions corresponding to the enumeration values corresponding to the enumeration types; and executing the interface element operation by using the interface element position.
The interface element position corresponding to the enumerated value may be obtained by: obtaining diagonal coordinates of the interface element corresponding to the enumeration value by using an interface element positioning tool, and calculating to obtain median coordinates by a median coordinate calculation method according to the obtained diagonal coordinates to be used as interface element positions corresponding to the enumeration value; the method for calculating the median coordinate is realized in an abstract element operation class or a screen implementation class corresponding to the equipment identifier.
The diagonal coordinates comprise coordinates of a first diagonal point and coordinates of a second diagonal point, for example coordinates of the upper left corner and the lower right corner.
The median coordinate calculation method may calculate the median coordinate by: and taking an integer part of an average value of the X-axis coordinates of the first diagonal points and the X-axis coordinates of the second diagonal points as an X-axis median coordinate value, and taking an integer part of an average value of the Y-axis coordinates of the first diagonal points and the Y-axis coordinates of the second diagonal points as a Y-axis median coordinate value, thereby obtaining a median coordinate.
The interface element operation comprises the following steps: and simulating a click operation and/or a gesture operation of the interface element.
The embodiment realizes the adaptation of the operation coordinate points of different equipment screens by utilizing the multi-state and dynamic loading mechanism of the language framework.
In addition, in the embodiment of the present invention, the details of the implementation of the interface adaptation apparatus for mobile-side automation test are already described in detail in the above interface adaptation method for mobile-side automation test, so that repeated descriptions are not repeated here.
Fig. 4 shows an exemplary system architecture 400 of an interface adaptation method for mobile-side automated testing or an interface adaptation apparatus for mobile-side automated testing, to which an embodiment of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, product information — just an example) to the terminal device.
It should be noted that the interface adapting method for the mobile terminal automation test provided in the embodiment of the present invention is generally executed by the server 405, and accordingly, the interface adapting apparatus for the mobile terminal automation test is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use in implementing a terminal device or server of an embodiment of the present application is shown. The terminal device or the server shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to the main step schematic may be implemented as computer software programs. For example, the disclosed embodiments of the invention include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the main step diagram. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The above-described functions defined in the system of the present application are executed when the computer program is executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The principal step diagrams and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the main step diagrams or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or block diagrams, and combinations of blocks in the block diagrams or block diagrams, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises an abstract element operation class definition module, a device identifier reading module, a screen implementation class instantiation module and an operation case execution module. The names of these modules do not in some cases constitute a definition of the module itself, for example, an abstract element operation class definition module may also be described as a "module for defining an abstract element operation class in an operation use case".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: defining an abstract element operation class in an operation case, wherein an interface element operation method applied to a mobile terminal is defined in the abstract element operation class; reading a device identifier of the configured mobile device; dynamically instantiating a screen implementation class corresponding to the device identifier, wherein the screen implementation class is pre-established and is a subclass of the abstract element operation class; and executing the operation case, wherein when the operation case is executed, the interface element operation method defined in the abstract element operation class is called, and a method realized by a screen implementation class corresponding to the equipment identifier is called in a polymorphic mode, so that the interface adaptation operation of the screen of the mobile equipment is completed by using the interface element position set in the screen implementation class, wherein the method realized by the screen implementation class is the interface element operation method defined in the abstract element operation class.
According to the technical scheme of the embodiment of the invention, an abstract element operation class is defined in an operation case, and an interface element operation method applied to a mobile terminal is defined in the abstract element operation class; dynamically instantiating a pre-established screen implementation class corresponding to the configured device identifier of the mobile device; and calling an interface element operation method defined in the abstract element operation class during the operation case execution, and calling a method realized by the screen realization class corresponding to the equipment identifier in a polymorphic mode, so that the interface adaptation operation on the screen of the mobile equipment is completed by using the interface element position set in the screen realization class. According to the embodiment of the invention, when the screen coordinate position simulation operation is required in the interface automation test case compiling, the screen position to be operated is separated from the existing interface automation test case code, and the interface automation case is separated from the interface adaptation operation, so that the problem that the interface layout can not be adapted by the hard code word quantity can be solved, the screen position is not required to be concerned for carrying out the automation test operation, and the screen adaptation in the automation test is realized.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An interface adaptation method for automated testing of a mobile terminal is characterized by comprising the following steps:
defining an abstract element operation class in an operation case, wherein an interface element operation method applied to a mobile terminal is defined in the abstract element operation class;
reading a device identifier of the configured mobile device;
dynamically instantiating a screen implementation class corresponding to the device identifier, wherein the screen implementation class is pre-established and is a subclass of the abstract element operation class;
and executing the operation case, wherein when the operation case is executed, the interface element operation method defined in the abstract element operation class is called, and a method realized by a screen implementation class corresponding to the equipment identifier is called in a polymorphic mode, so that the interface adaptation operation of the screen of the mobile equipment is completed by using the interface element position set in the screen implementation class, wherein the method realized by the screen implementation class is the interface element operation method defined in the abstract element operation class.
2. The method of claim 1, wherein the step of dynamically instantiating the screen implementation class corresponding to the device identifier is preceded by:
obtaining a device identifier of the mobile device by connecting the mobile device or accessing the mobile terminal application through a simulator;
establishing a screen implementation class corresponding to the obtained device identifier, and implementing the interface element operation method defined in the abstract element operation class in the screen implementation class, wherein the implementation process comprises the following steps: creating an enumeration type corresponding to a parameter of the interface element operation method defined in the abstract element operation class, wherein the parameter is an interface element naming identifier; in an execution condition corresponding to an enumeration value corresponding to the enumeration type, transmitting the interface element position corresponding to the enumeration value; and executing the interface element operation by using the interface element position.
3. The method of claim 2, wherein the interface element position corresponding to the enumerated value is obtained by:
obtaining diagonal coordinates of the interface element corresponding to the enumeration value by using an interface element positioning tool, and calculating a median coordinate by a median coordinate calculation method according to the obtained diagonal coordinates to serve as the interface element position corresponding to the enumeration value; wherein the median coordinate calculation method is implemented in the abstract element operation class or a screen implementation class corresponding to the device identifier.
4. The method of claim 3, wherein the diagonal coordinates comprise coordinates of a first diagonal point and coordinates of a second diagonal point,
the median coordinate calculation method calculates the median coordinate by:
and taking an integer part of an average value of the X-axis coordinates of the first diagonal points and the X-axis coordinates of the second diagonal points as an X-axis median coordinate value, and taking an integer part of an average value of the Y-axis coordinates of the first diagonal points and the Y-axis coordinates of the second diagonal points as a Y-axis median coordinate value, thereby obtaining the median coordinate.
5. The method of claim 1, wherein the interface element operation comprises: and simulating click operation and/or gesture operation of the interface element.
6. An interface adapting device for automated testing of a mobile terminal, comprising:
the abstract element operation class definition module is used for defining an abstract element operation class in an operation case, and the abstract element operation class defines an interface element operation method applied to the mobile terminal;
a device identifier reading module for reading a device identifier of the configured mobile device;
a screen implementation class instantiation module, configured to dynamically instantiate a screen implementation class corresponding to the device identifier, where the screen implementation class is pre-established and is a subclass of the abstract element operation class;
and the operation case execution module is used for executing the operation case, calling the interface element operation method defined in the abstract element operation class when the operation case is executed, and calling a method realized by a screen realization class corresponding to the equipment identifier in a polymorphic mode, so that the interface adaptation operation of the screen of the mobile equipment is completed by using the interface element position set in the screen realization class, wherein the method realized by the screen realization class is the interface element operation method defined in the abstract element operation class.
7. The apparatus of claim 6, further comprising a screen implementation class creation module to:
obtaining a device identifier of the mobile device by connecting the mobile device or accessing the mobile terminal application through a simulator;
establishing a screen implementation class corresponding to the obtained device identifier, and implementing the interface element operation method defined in the abstract element operation class in the screen implementation class, wherein the implementation process comprises the following steps: creating an enumeration type corresponding to a parameter of the interface element operation method defined in the abstract element operation class, wherein the parameter is an interface element naming identifier; in an execution condition corresponding to an enumeration value corresponding to the enumeration type, transmitting the interface element position corresponding to the enumeration value; and executing the interface element operation by using the interface element position.
8. The apparatus of claim 7, wherein the interface element position corresponding to the enumerated value is obtained by:
obtaining diagonal coordinates of the interface element corresponding to the enumeration value by using an interface element positioning tool, and calculating a median coordinate by a median coordinate calculation method according to the obtained diagonal coordinates to serve as the interface element position corresponding to the enumeration value; wherein the median coordinate calculation method is implemented in the abstract element operation class or a screen implementation class corresponding to the device identifier.
9. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method recited in any of claims 1-5.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201910853249.XA 2019-09-10 2019-09-10 Interface adaptation method and device for mobile terminal automatic test Active CN112559311B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910853249.XA CN112559311B (en) 2019-09-10 2019-09-10 Interface adaptation method and device for mobile terminal automatic test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910853249.XA CN112559311B (en) 2019-09-10 2019-09-10 Interface adaptation method and device for mobile terminal automatic test

Publications (2)

Publication Number Publication Date
CN112559311A true CN112559311A (en) 2021-03-26
CN112559311B CN112559311B (en) 2023-08-04

Family

ID=75029024

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910853249.XA Active CN112559311B (en) 2019-09-10 2019-09-10 Interface adaptation method and device for mobile terminal automatic test

Country Status (1)

Country Link
CN (1) CN112559311B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090235229A1 (en) * 2007-12-10 2009-09-17 International Business Machines Corporation Graphical Modelization of User Interfaces for Data Intensive Applications
CN109446092A (en) * 2018-10-31 2019-03-08 北京微播视界科技有限公司 The method, apparatus and electronic equipment be identified to user interface UI element
WO2019144680A1 (en) * 2018-01-23 2019-08-01 网易(杭州)网络有限公司 Automatic testing method and apparatus, storage medium and electronic device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090235229A1 (en) * 2007-12-10 2009-09-17 International Business Machines Corporation Graphical Modelization of User Interfaces for Data Intensive Applications
WO2019144680A1 (en) * 2018-01-23 2019-08-01 网易(杭州)网络有限公司 Automatic testing method and apparatus, storage medium and electronic device
CN109446092A (en) * 2018-10-31 2019-03-08 北京微播视界科技有限公司 The method, apparatus and electronic equipment be identified to user interface UI element

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
迟晓波;冯雁;: "手机MMI自动化测试系统的关键技术研究", 计算机测量与控制, no. 02 *

Also Published As

Publication number Publication date
CN112559311B (en) 2023-08-04

Similar Documents

Publication Publication Date Title
CN113010827B (en) Page rendering method and device, electronic equipment and storage medium
US11741002B2 (en) Test automation systems and methods using logical identifiers
CN110531962A (en) Development process method, equipment and the computer readable storage medium of small routine
CN103984626A (en) Method and device for generating test-case script
CN114911465B (en) Method, device and equipment for generating operator and storage medium
US20200110592A1 (en) Auto-deployment of applications
CN110020231A (en) Webpage capture method and device thereof
CN112015468A (en) Interface document processing method and device, electronic equipment and storage medium
CN113392346A (en) Path processing method and device for resource file, electronic equipment and storage medium
CN114036443A (en) Page generation method and device
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
JP7255827B2 (en) METHOD AND APPARATUS FOR TIME SELECTION WHEN TEST SCRIPT RECORDING
CN114115855A (en) Code multiplexing method and device, computer readable storage medium and electronic equipment
CN113495498A (en) Simulation method, simulator, device, and medium for hardware device
CN113760733A (en) Unit testing method and device
CN112559311B (en) Interface adaptation method and device for mobile terminal automatic test
CN111813407A (en) Game development method, game running device and electronic equipment
CN114741294A (en) Page debugging method, device, equipment and storage medium
CN116679912A (en) Code generation method, apparatus, device, storage medium, and computer program
CN116009847A (en) Code generation method, device, electronic equipment and storage medium
CN115269431A (en) Interface testing method and device, electronic equipment and storage medium
CN109960526A (en) A kind of application program packaging method and device
CN114969591A (en) Page rendering method and device, electronic equipment and readable storage medium
CN113849164A (en) Data processing method and device, electronic equipment and memory
CN108170557B (en) Method and apparatus for outputting information

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
GR01 Patent grant
GR01 Patent grant