Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for selecting time when recording a test script, which can simulate time selection of a user only through a code without user participation, and can be applied to different mobile device models, operating system versions, screen sizes, resolutions, different applications, and the like, and the test script has good compatibility and high flexibility, and saves a large amount of labor cost.
To achieve the above object, according to an aspect of the embodiments of the present invention, a method for selecting time when recording a test script is provided.
A method for selecting time when a test script is recorded comprises the following steps: identifying an initial time of display of a time control, the initial time comprising at least one time element and an initial value thereof; for each time element, acquiring a coordinate distance between an initial value and an adjacent value of the time element, wherein the adjacent value is a value adjacent to the initial value in the values of the same time element of the time control, and calculating a difference value between a target value of the time element and the initial value in a preset target time; and simulating the user to finish time selection according to the coordinate distance and the difference value.
Optionally, the obtaining of the coordinate distance between the initial value and the adjacent value of the time element comprises: respectively acquiring an initial value of the time element and a coordinate value of an adjacent value through a coordinate acquisition tool; and calculating the absolute value of the difference between the coordinate value of the initial value and the coordinate value of the adjacent value to obtain the coordinate distance.
Optionally, simulating the user completion time selection according to the coordinate distance and the difference value comprises: judging the sliding direction according to the difference value; taking the coordinate distance as a unit distance of each sliding, sliding the time element along the sliding direction and acquiring a current value after each sliding; when the current value is equal to the target value, time selection is completed.
Optionally, simulating the user completion time selection according to the coordinate distance and the difference value comprises: judging the sliding direction according to the difference value; obtaining the sliding distance of the time element according to the coordinate distance and the absolute value of the difference; and sliding the time element along the sliding direction according to the sliding distance so as to enable the sliding value to be the target value, and finishing time selection.
According to another aspect of the embodiment of the invention, a device for selecting time when recording the test script is provided.
An apparatus for time selection for recording of test scripts, comprising: the time identification module is used for identifying the initial time displayed by the time control, and the initial time comprises at least one time element and an initial value thereof; the numerical value processing module is used for acquiring the coordinate distance between the initial value and the adjacent value of each time element, wherein the adjacent value is the value adjacent to the initial value in the values of the same time element of the time control, and calculating the difference value between the target value and the initial value of the time element in the preset target time; and the time selection module is used for simulating the completion of time selection of the user according to the coordinate distance and the difference value.
Optionally, the numerical processing module is further configured to: respectively acquiring an initial value of the time element and a coordinate value of an adjacent value through a coordinate acquisition tool; and calculating the absolute value of the difference between the coordinate value of the initial value and the coordinate value of the adjacent value to obtain the coordinate distance.
Optionally, the time selection module is further configured to: judging the sliding direction according to the difference value; taking the coordinate distance as a unit distance of each sliding, sliding the time element along the sliding direction and acquiring a current value after each sliding; when the current value is equal to the target value, time selection is completed.
Optionally, the time selection module is further configured to: judging the sliding direction according to the difference value; obtaining the sliding distance of the time element according to the coordinate distance and the absolute value of the difference; and sliding the time element along the sliding direction according to the sliding distance so as to enable the sliding value to be the target value, and finishing time selection.
According to another aspect of the embodiment of the invention, an electronic device for time selection when a test script is recorded is provided.
An electronic device for time selection when a test script is recorded, comprising: one or more processors; the storage device 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 method for selecting the time when the test script is recorded, which is provided by the embodiment of the invention.
According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.
A computer-readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for selecting time when recording a test script according to an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: identifying an initial time displayed by the time control, the initial time comprising at least one time element and an initial value thereof; for each time element, acquiring a coordinate distance between an initial value and an adjacent value of the time element, wherein the adjacent value is a value adjacent to the initial value in the values of the same time element of the time control, and calculating a difference value between a target value and the initial value of the time element in preset target time; the user is simulated according to the coordinate distance and the difference value to complete time selection, the user can be simulated only through codes without participation of the user, the method is applicable to different mobile equipment models, operating system versions, screen sizes, resolution ratios, different applications and the like, the test script is good in compatibility and high in flexibility, and a large amount of labor cost is saved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
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.
In order to solve the technical problems in the prior art, the invention provides a method for selecting time when a test script is recorded, which can simulate the time selection of a user only through codes without the participation of the user, is suitable for different mobile equipment models, operating systems, screen sizes, resolutions and different applications, has good compatibility of the test script, and saves a large amount of labor cost.
Fig. 1 is a schematic diagram illustrating main steps of a method for selecting time when recording a test script according to an embodiment of the present invention. As shown in fig. 1, the method for selecting time when recording a test script according to the embodiment of the present invention mainly includes the following steps S101 to S103.
Step S101: identifying an initial time displayed by a time control, wherein the initial time comprises at least one time element and an initial value thereof;
step S102: for each time element, acquiring a coordinate distance between an initial value and an adjacent value of the time element, wherein the adjacent value is a value adjacent to the initial value in the values of the same time element of the time control, and calculating a difference value between a target value and the initial value of the time element in preset target time;
step S103: and simulating the user to finish time selection according to the coordinate distance and the difference value.
According to the embodiment of the invention, when the initial time of the time control display is identified, the image identification technology can be used for realizing the display. The initial time includes time elements such as year, month, day, hour, minute, second, and the like.
According to an embodiment of the present invention, when obtaining the coordinate distance between the initial value of the time element and the adjacent value, the following steps may be specifically performed:
respectively acquiring an initial value of a time element and a coordinate value of an adjacent value through a coordinate acquisition tool;
and calculating the absolute value of the difference between the coordinate value of the initial value and the coordinate value of the adjacent value to obtain the coordinate distance.
The coordinate acquisition tool can be integrated in an automatic test tool, or can be self-contained in a mobile equipment system. When the initial value of the time element and the coordinate values of the adjacent values are obtained, the coordinate values of the upper left corner (or the lower left corner, the upper right corner, the lower right corner, etc.) of the space occupied by each numerical value (including the initial value and the adjacent values) may be obtained, or the coordinate values of the center of the space occupied by each numerical value may be obtained.
The distance between two adjacent numerical values can be obtained by calculating the coordinate distance between the initial value and the adjacent value. In general, when the time control is set, the distance between two adjacent numerical values is fixed.
According to another embodiment of the present invention, when simulating the user completion time selection according to the coordinate distance and the difference, the method may specifically be performed according to the following steps:
judging the sliding direction according to the difference value;
taking the coordinate distance as a unit distance of each sliding, sliding the time element along the sliding direction and acquiring a current value after each sliding;
when the current value is equal to the target value, the time selection is completed.
According to another embodiment of the present invention, when simulating the user completion time selection according to the coordinate distance and the difference, the following steps may be specifically performed:
judging the sliding direction according to the difference value;
obtaining the sliding distance of the time element according to the coordinate distance and the absolute value of the difference;
and according to the sliding distance, sliding the time element along the sliding direction to enable the sliding value to be a target value, and finishing time selection.
The difference between the initial value and the target value of the time element in the preset target time may be a positive number, and may also be a negative number and 0. When the difference value is 0, the initial value is equal to the target value, and the initial value is directly used as the selected time without moving the time element; when the difference is a positive number or a negative number, the sliding direction needs to be determined according to the numerical value change trend of the time element in the time control. Specifically, for example: assuming that the time elements in the time control are arranged up and down and are increased progressively from top to bottom, when the difference is a positive number, the sliding direction is upward; when the difference is negative, the sliding direction is downward.
After the direction of the slide is determined, the time element can be slid along the direction of the slide to select the time. In specific execution, the coordinate distance can be taken as a unit distance of each sliding, and a current value after the sliding is obtained and judged whether to be equal to a target value or not every time the sliding is performed; or the total sliding distance is calculated according to the coordinate distance and the absolute value of the difference, and then the target value is directly slid once according to the sliding distance.
The following describes a specific implementation process of the method for selecting time when recording the test script, by taking date selection (year, month, and day) as an example. When the user completes time selection according to the coordinate distance and the difference value, a method of taking the coordinate distance as a unit distance of each sliding, acquiring a current value after the sliding and judging whether the current value is equal to a target value or not every sliding is taken as an example for introduction.
FIG. 2 is a schematic diagram of an interface for date selection according to one embodiment of the invention. As shown in FIG. 2, which illustrates a common interface diagram for a date control, time selection is made by a pull-down scrolling of time elements, including year, month and day. In this example, the target time isday 27 of 6 months of 2015, with time selection by sliding the time element below. In the prior art, the time element is generally slid by manually sliding the screen, so that the value of the time element is changed until the current value of the time element is equal to the target value. In the embodiment of the present invention, the time selection by the user is simulated by the proposed date selection device, please refer to fig. 3.
Fig. 3 is a schematic structural diagram of a device for date selection according to an embodiment of the present invention. As shown in fig. 3, an apparatus 300 for date selection according to an embodiment of the present invention includes 1 inception date recognition unit 301, 1 time element coordinate information recognition unit 302, 1 time element coordinate storage unit 303, 1 time element calculation search unit 304, and 1 time element simulation selection unit 305.
The device 300 for selecting a date according to the embodiment of the present invention receives a preset target date value as a parameter assignment value before use. When the device 300 runs, the system automatically clicks and pops up a drop-down selection box, searches for a selection target date option and the like, and then completes a series of actions;
an inception date recognition unit 301 for recognizing an inception date in the pull-down scroll menu, the inception date including 3 time elements (year, month, day) and corresponding initial values, using an image recognition technique;
a time element coordinate information identification unit 302 for identifying coordinate information of different values of each time element in the pull-down scrolling date control and sending the identified coordinate information to a time element coordinate storage unit 303;
the time element coordinate storage unit 303 is configured to store coordinate information of different values of time elements, and establish a correspondence table between values and coordinates of each time element. Meanwhile, calculating the coordinate distance between the initial value of each time element and the adjacent value as the unit distance of the sliding date;
a time element calculation search unit 304 for calculating a difference between a target value and an initial value of a time element, and performing a cyclic decision search starting from the initial value until the target value of the time element is found;
and a time element simulation selection unit 305 for simulating the tester to complete the selection of the target date according to the calculation and search result of the time element calculation search unit 304.
FIG. 4 is a schematic view of an interface for making year selections, in accordance with one embodiment of the present invention. As shown in fig. 4, in which only an interface for selecting one time element (year) is shown, time selection is performed by pulling down the scroll time element. Where the initial value of the time element (year) is 1978 and when the target value to be selected is 1990, the screen needs to be slid up to find 1990. In the prior art, when recording a test script, the time element of the year is used as an operation object, and the user manually performs a sliding action on the operation object to find the target value 1990, thereby completing the year selection. In the embodiment of the present invention, the time selection performed by the user is simulated by the proposed method for selecting the year, and the specific implementation flow is shown in fig. 5.
FIG. 5 is a flow chart of an implementation of year selection according to an embodiment of the present invention. As shown in fig. 5, the implementation process of year selection according to the embodiment of the present invention mainly includes the following steps:
1) identifying an initial value of a time element (year) in a pull-down scrolling date control through an image identification technology;
2) by a coordinate acquisition tool integrated in the automated test tool, coordinate values of the initial value of the time element are acquired and recorded (for example: the coordinates of the upper left corner of the area corresponding to the initial value);
3) the adjacent values of the initial value of the time element are acquired and recorded by a coordinate acquisition tool integrated in the automated test tool (i.e.: the previous or next value of the initial value) of the coordinate values (for example: the upper left corner coordinate of the region corresponding to the neighborhood);
4) calculating the absolute value of the difference between the coordinate value of the initial value and the coordinate value of the adjacent value to obtain a coordinate distance, and taking the coordinate distance as a unit distance of sliding for one year each time;
5) calculating the difference value between the target value and the initial value of the time element (year) transmitted in advance;
6) it is determined whether the current value is the input target value. If the difference value between the input target value and the current value is 0, selecting the current value to complete year selection, and ending the process; if the difference value is positive, sliding upwards for one grid, acquiring a value after sliding as a current value, circularly judging and sliding until the current value is equal to the target value, wherein the number of the sliding grids is the absolute value of the difference value between the target value and the initial value; if the difference value is negative, sliding downwards for one grid, acquiring a value after sliding as a current value, and circularly judging and sliding until the current value is equal to the target value, wherein the number of the sliding grids is the absolute value of the difference value between the target value and the initial value;
7) and simulating the tester to complete the year selection according to the calculation and search results.
Likewise, when a search for the month and date is required, it is also performed in accordance with the search selection method for the year. In general, when the year becomes larger from top to bottom, the time element (year) to be selected may be slid in the sliding direction described in the above-described step 6); when the year is successively smaller from top to bottom, the time element (year) to be selected may be slid in the direction opposite to the sliding direction described in the above-described step 6). The present invention is not limited to the case where values of the same time element are arranged vertically, but is also applicable to the case where values of the same time element are arranged horizontally. The above scenarios are all within the protection scope of the technical solution of the present invention, and those skilled in the art can perform corresponding expansion according to the needs of practical application.
Fig. 6 is a schematic diagram of main blocks of an apparatus for selecting time when recording a test script according to an embodiment of the present invention. As shown in fig. 6, theapparatus 600 for selecting time when recording a test script according to an embodiment of the present invention mainly includes atime identification module 601, anumerical processing module 602, and atime selection module 603.
Thetime identification module 601 is configured to identify an initial time displayed by the time control, where the initial time includes at least one time element and an initial value thereof;
anumerical processing module 602, configured to, for each time element, obtain a coordinate distance between an initial value and an adjacent value of the time element, where the adjacent value is a value adjacent to the initial value in values of the same time element of the time control, and calculate a difference between a target value of the time element and the initial value in a preset target time;
and atime selection module 603, configured to simulate a user to complete time selection according to the coordinate distance and the difference.
According to an embodiment of the present invention, thenumerical processing module 602 may further be configured to:
respectively acquiring an initial value of the time element and a coordinate value of an adjacent value through a coordinate acquisition tool;
and calculating the absolute value of the difference between the coordinate value of the initial value and the coordinate value of the adjacent value to obtain the coordinate distance.
According to another embodiment of the present invention, thetime selection module 603 may further be configured to:
judging the sliding direction according to the difference value;
taking the coordinate distance as a unit distance of each sliding, sliding the time element along the sliding direction and acquiring a current value after each sliding;
when the current value is equal to the target value, time selection is completed.
According to yet another embodiment of the present invention, thetime selection module 603 may be further configured to:
judging the sliding direction according to the difference value;
obtaining the sliding distance of the initial time element according to the coordinate distance and the absolute value of the difference;
and sliding the time element along the sliding direction according to the sliding distance so as to enable the sliding value to be the target value, and finishing time selection.
According to the technical scheme of the embodiment of the invention, the initial time displayed by the time control is identified, and the initial time comprises at least one time element and an initial value thereof; for each time element, acquiring a coordinate distance between an initial value and an adjacent value of the time element, wherein the adjacent value is a value adjacent to the initial value in the values of the same time element of the time control, and calculating a difference value between a target value and the initial value of the time element in preset target time; the user is simulated according to the coordinate distance and the difference value to complete time selection, the user can be simulated only through codes without participation of the user, the method is applicable to different mobile equipment models, operating system versions, screen sizes, resolution ratios, different applications and the like, the test script is good in compatibility and high in flexibility, and a large amount of labor cost is saved.
Fig. 7 illustrates anexemplary system architecture 700 of a method for time selection upon test script recording or an apparatus for time selection upon test script recording to which embodiments of the present invention may be applied.
As shown in fig. 7, thesystem architecture 700 may includeterminal devices 701, 702, 703, anetwork 704, and aserver 705. Thenetwork 704 serves to provide a medium for communication links between theterminal devices 701, 702, 703 and theserver 705.Network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use theterminal devices 701, 702, 703 to interact with aserver 705 over anetwork 704, to receive or send messages or the like. Theterminal devices 701, 702, 703 may have installed thereon various communication client applications, such as a shopping-like application, a web browser application, a search-like application, an instant messaging tool, a mailbox client, social platform software, etc. (by way of example only).
Theterminal devices 701, 702, 703 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.
Theserver 705 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 theterminal devices 701, 702, 703. 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, target push information, product information — just an example) to the terminal device.
It should be noted that the method for selecting time when recording the test script provided by the embodiment of the present invention is generally executed by theserver 705, and accordingly, the apparatus for selecting time when recording the test script is generally disposed in theserver 705.
It should be understood that the number of terminal devices, networks, and servers in fig. 7 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 8, shown is a block diagram of acomputer system 800 suitable for use with a terminal device or server implementing an embodiment of the present invention. The terminal device or the server shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 8, thecomputer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from astorage section 808 into a Random Access Memory (RAM) 803. In theRAM 803, various programs and data necessary for the operation of thesystem 800 are also stored. TheCPU 801,ROM 802, andRAM 803 are connected to each other via abus 804. An input/output (I/O)interface 805 is also connected tobus 804.
The following components are connected to the I/O interface 805: aninput portion 806 including a keyboard, a mouse, and the like; anoutput section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; astorage portion 808 including a hard disk and the like; and acommunication section 809 including a network interface card such as a LAN card, a modem, or the like. Thecommunication section 809 performs communication processing via a network such as the internet. Adrive 810 is also connected to the I/O interface 805 as necessary. Aremovable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on thedrive 810 as necessary, so that a computer program read out therefrom is mounted on thestorage section 808 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure 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 illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through thecommunication section 809 and/or installed from theremovable medium 811. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 801.
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 invention, 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 the present invention, 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 flowchart 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 invention. In this regard, each block in the flowchart 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 flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware. The described units or modules may also be provided in a processor, and may be described as: a processor includes a time identification module, a numerical processing module, and a time selection module. Where the names of these units or modules do not in some cases constitute a limitation on the units or modules themselves, for example, the time identification module may also be described as a "module for identifying the initial time of the time control display".
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: identifying an initial time of display of a time control, the initial time comprising at least one time element and an initial value thereof; for each time element, acquiring a coordinate distance between an initial value and an adjacent value of the time element, wherein the adjacent value is a value adjacent to the initial value in the values of the same time element of the time control, and calculating a difference value between a target value of the time element and the initial value in a preset target time; and simulating the user to finish time selection according to the coordinate distance and the difference value.
According to the technical scheme of the embodiment of the invention, the initial time displayed by the time control is identified, and the initial time comprises at least one time element and an initial value thereof; for each time element, acquiring a coordinate distance between an initial value and an adjacent value of the time element, wherein the adjacent value is a value adjacent to the initial value in the values of the same time element of the time control, and calculating a difference value between a target value and the initial value of the time element in preset target time; the user is simulated according to the coordinate distance and the difference value to complete time selection, the user can be simulated only through codes without participation of the user, the method is applicable to different mobile equipment models, operating system versions, screen sizes, resolution ratios, different applications and the like, the test script is good in compatibility and high in flexibility, and a large amount of labor cost is saved.
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.