A method, system, readable storage medium and device for encapsulating a date control

By using type parameters and status parameters in the date control for multiple verification, combined with date offset and time zone correction, the problems of low encapsulation and incomplete verification of date control are solved, improving the operation ease and verification accuracy of date control.

CN120045245BActive Publication Date: 2025-07-04INSPUR GENERSOFT CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510517620.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-07-04
Estimated Expiration
2045-04-24

AI Technical Summary

Technical Problem

The existing date control has a small encapsulation granularity and complex operation. Test verification is only for the process, and cannot effectively verify the correctness of the data, and cannot handle complex time zone and style verification.

Method used

By using two type parameters to indicate the operation scenario of the date control, multiple verifications are performed, including the first check and the second check, and the expected value is corrected in combination with the date offset and the client time zone to ensure consistency of data types and states.

Benefits of technology

It achieves comprehensive coverage of date control operation scenarios, reduces the difficulty of automated writing, improves verification accuracy and efficiency, and ensures the legitimacy and relevance of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045245B_ABST
    Figure CN120045245B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of component encapsulation, and provides a method, a system, a readable storage medium and a device for encapsulating a date control. The present invention uses two type parameters to indicate the current operation scenario of the date control, and determines the data type of the date control for different operation scenarios, which can cover all scenarios, and performs multiple validations on the test return result of the date control. When validating, a date offset and the time zone where the client is located are introduced to correct the expected value, effectively improving its accuracy, and solving the problems in the prior art that the encapsulation granularity is small, the operation is relatively complex, and the test validation only validates the process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of component encapsulation, and particularly relates to a method, system, readable storage medium and device for encapsulating a date control. Background Technique

[0002] The statements in this part only provide background technical information related to the present invention, and do not necessarily constitute prior art.

[0003] A date control is a control used to specify or select a date / time value, which plays an important role in actual business. Encapsulating or processing the date control can provide users with richer functions and better user experience, and enhance the function expansion of the date control.

[0004] However, for the existing encapsulation or processing of date controls, on the one hand, the granularity of each control behavior is small. For example, clicking on the date control, date selection, date popup paging, and date popup clearing are all different usage scenarios / methods. The number of code lines corresponding to each use case is large and the code overlap degree of different use cases is high. When the corresponding testers develop, they need to have an in-depth understanding of the development documents, and the code workload is also large. On the other hand, the existing encapsulation verification generally only mechanically executes the operation process, only verifying whether the process is correct, and cannot verify whether the data generated by the process is correct.

[0005] Although some researchers have proposed verification of the data generated by the process, such as the Chinese invention patent with the invention publication number CN118170357A and the invention name of time control generation method, device, storage medium and electronic device, which mentions whether the time accuracy and range of the control content are within the preset accuracy and range, this kind of verification is a relatively simple threshold comparison and cannot implement more complex verifications such as styles and time zones. Summary of the Invention

[0006] In order to solve the above problems, the present invention provides a method, system, readable storage medium and device for encapsulating a date control. The present invention uses two type parameters to indicate the current operation scenario of the date control, determines the data type of the date control for different operation scenarios, can cover all scenarios, and performs multiple verifications on the return result of the date control, effectively improving its accuracy.

[0007] According to some embodiments, the present invention adopts the following technical solutions:

[0008] A method for encapsulating a date control includes the following steps:

[0009] Obtain test time data and the test return result of the date control in the operation scenario, and perform the first verification and the second verification on the test return result in sequence;

[0010] The process of the first verification is to calculate the original expected value based on the test time data and the pre-configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes; if not, it is determined whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes.

[0011] The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0012] As an alternative implementation, the operation scenario includes: the first operation scenario, the second operation scenario, and the third operation scenario. Among them, if the data type is a date type and the optional status is optional, it is the first operation scenario. In the first operation scenario, the date data is determined by selecting the data in the date pop-up panel.

[0013] If the data type is a date type and the optional status is non-optional, it is the second operation scenario. In the second operation scenario, the date data is determined by inputting data.

[0014] If the data type is a non-date type and the optional status is optional, it is the third operation scenario. In the third operation scenario, the date data is determined by selecting a shortcut key.

[0015] Determine the operation scenario according to the type and optional status of the test time data.

[0016] As an alternative implementation, preprocess the test return result of the date control in the operation scenario. Split the data in the test return result into an array of numeric types and an array of non-numeric types. Concatenate the elements of the array of numeric types into a complete character, determine the length of the complete character, and judge the preliminary date type according to the length of the complete character. Extract the characters in the array of non-numeric types, and correct the preliminary date type according to the character type and quantity. Through mask formatting processing, obtain the final test return result.

[0017] As a further implementation, judging the preliminary date type according to the length of the complete character includes: if the length of the complete character is 4, it is considered as year-type data; if the length of the complete character is 6, it is considered as year-month type data or time type data; if the length of the complete character is 8, it is considered as year-month-day type data; if the length of the complete character is 14, it is considered as year-month-day and time type data; if the length of the complete character is 16, it is considered as date range data or data with time zone.

[0018] If the length of the complete character is other lengths, it is considered illegal data or error data.

[0019] As a further implementation, according to the character type and quantity, the process of correcting the preliminary date type includes that if the characters are the same separator, the number of separators exceeds one and the separator is not the predetermined separator, combining the preliminary date type, according to the principle that the year occupies four digits, the month occupies two digits, and the day occupies two digits, dividing the complete character from left to right to obtain the final test return result;

[0020] If the characters are different separators and contain the predetermined separator, combining the preliminary date type, according to the principle that the year occupies four digits, the month occupies two digits, the day occupies two digits, the hour occupies two digits, the minute occupies two digits, and the second occupies two digits, dividing the complete character from left to right to obtain the final test return result.

[0021] As an alternative implementation, the process according to the test time data and the pre-configured date offset includes: if the date offset is zero, using the original expected value as the expected value after introducing the date offset; if the date offset is greater than zero, using the value obtained by adding the date offset to the original expected value as the expected value after introducing the date offset; if the date offset is less than zero, using the value obtained by subtracting the date offset from the original expected value as the expected value after introducing the date offset.

[0022] As a further implementation, the process of correcting the original expected value according to the time zone where the date control belongs to the client includes: recording the time of operating the date control, determining the time stamp of the Coordinated Universal Time (UTC) at this time, and combining the time zone where the client where the date control is located to correct the time zone of the expected value after introducing the date offset.

[0023] As an alternative implementation, the process of determining whether the corrected expected value is correct includes: determining whether the corrected expected value is illegal data. If so, it is considered that the corrected expected value is incorrect; determining whether the linkage result between the corrected expected value and the date data of the operating date control is correct. If not, it is considered that the corrected expected value is incorrect.

[0024] A date control encapsulation system includes:

[0025] A data acquisition module, configured to acquire test time data and the test return result of the date control in the operation scenario;

[0026] A double-layer verification module, configured to perform the first verification and the second verification on the test return result in sequence;

[0027] The process of the first verification is to calculate the original expected value based on the test time data and the pre-configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs is located, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes; if not, it is determined whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes.

[0028] The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0029] A computer-readable storage medium is used to store computer instructions. When the computer instructions are executed by a processor, the steps in the above method are completed.

[0030] An electronic device includes a memory, a processor, and computer instructions stored on the memory and running on the processor. When the computer instructions are run by the processor, the steps in the above method are completed.

[0031] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0032] Through two parameters, namely the type and status of the data, the present invention can determine the operation scenario / method of the date control, and ensure comprehensive coverage of the operation scenarios of all date controls, greatly reducing the difficulty of automated writing and improving the user experience.

[0033] The present invention provides a data verification process for test encapsulation, utilizes a double-layer / double verification mechanism, introduces a date offset and the time zone where the client is located when verifying, corrects the expected value, and does not mechanically verify the result during the verification process, fully considering the legality and relevance of the data to ensure the accuracy of the verification result.

[0034] The present invention places the first verification in the first layer and the second verification in the second layer, which can ensure that the most important part is verified first, and gives the second verification process time to obtain elements related to the optional status, which can improve the verification efficiency and save time in the overall verification process.

[0035] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The specification drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention.

[0037] Figure 1 It is a schematic flowchart of a method for encapsulating a date control in an embodiment;

[0038] Figure 2 It is a schematic diagram of the process for determining the operation scenario of a date control in an embodiment;

[0039] Figure 3 It is a schematic diagram of the process for identifying the test return result in an embodiment;

[0040] Figure 4 It is a schematic diagram of a two - fold verification process in an embodiment;

[0041] Figure 5 It is a schematic diagram of the system structure for encapsulating a date control in an embodiment;

[0042] Figure 6 It is a schematic diagram of an electronic device in an embodiment. Detailed implementation manners

[0043] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0044] It should be noted that the following detailed descriptions are all illustrative and are intended to provide further explanations of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs.

[0045] It should be noted that the terms used herein are only for describing specific implementation manners and are not intended to limit the exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0046] Without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.

[0047] Embodiment 1

[0048] A method for encapsulating a date control, as Figure 1 shown, includes the following steps:

[0049] S1. Obtain the test time data and the test return result of the date control in the operation scenario, and perform the first verification and the second verification on the test return result in sequence;

[0050] S2. The process of the first verification is as follows: Calculate the original expected value based on the test time data and the pre-configured date offset. Then, correct the original expected value according to the time zone where the client to which the date control belongs. Determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes. If not, determine whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes.

[0051] S3. The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0052] Considering that in the business system, the scenarios where users use the date control mainly include the following:

[0053] (1) Selection: In general operations, click the date control, and through the operation of switching the year, month, and day components on the control page, select the desired date; or click the date control and select the shortcut keys on the control page, such as Today, Beginning of Month, Beginning of Quarter, etc.

[0054] (2) Input: Directly input specific dates, including legal and illegal dates.

[0055] On the other hand, from the analysis of the control types, there are the following two types of date controls:

[0056] (1) Single date control, that is, there is only one pop-up window after clicking the date control, which is often used for data entry.

[0057] (2) Interval date control, that is, there are two date control pop-up windows after clicking the date control, and a range of dates can be selected, such as 2024-01-01—2024-12-31. After selection, two dates will be bounced back, which is often used for query.

[0058] From a more detailed function division, these two types of controls have several different display effects:

[0059] (1) Different mask formats, such as YYYY-MM-DD, YYYY year MM month DD day.

[0060] (2) Due to business restrictions, some dates cannot be actually selected after clicking the pop-up window, such as only allowing the selection of dates in the current month.

[0061] (3) Different date types, such as year type (taking 2024 as an example), month type (taking 2024-01 as an example), year-month-day type (taking 2024-01-01 as an example), date-time type (taking 2024-01-01 12:00:00 as an example), time type (taking 10:59:59 as an example), time zone data (taking 2025-04-11T08:04:31.55Z as an example).

[0062] (4) Dynamic dates need to be calculated dynamically based on the date of the day. For example, when testing, it is necessary to test the date selection situation at some special time points, such as February 28th, February 29th, etc. At this time, the server time needs to be adjusted to the baseline time, which results in a deviation from the actual time. When it is necessary to select a date based on a special date (the day after February 28th), the selection results for leap years and non-leap years are inconsistent.

[0063] In summary, in the actual business situation, there is a possibility of combination among these types, which makes the behavior of the date component complex. If a method is encapsulated for each type, it will make the experience of test developers using UI automation for coding extremely poor and it will be difficult to maintain the code later, bringing extremely high maintenance costs. The solution provided in this embodiment can handle a control with as few methods or operation scenarios as possible. The code for locating elements cannot be included in such methods, which reduces the difficulty of UI automation coding and also provides a solid foundation for later supporting the generation of UI automation code by large models.

[0064] In this embodiment, if the type of test data is a date type and the selectable state is selectable, it is the first operation scenario, that is, the date_select method scenario;

[0065] If the type of test data is a date type and the selectable state is unselectable, it is the second operation scenario, that is, the date_input method scenario;

[0066] If the type of test data is a non-date type and the selectable state is selectable, it is the third operation scenario, that is, the date_btn_select method scenario.

[0067] The test data is determined by the tester's use cases. For example, date_fast_select(id, '2025-05-16', 'optional'), which means clicking on the date control with this id. By parsing the test data and the optional parameters, it is known that a date control of the year-month-day type needs to be clicked to select, and the code will then click on the date data '2025-05-16'. Or, date_fast_select(id, 'February 30, 2025', 'not optional'), which is to input the value 'February 30, 2025' in the date control; date_fast_select(id, 'Today', 'optional'), which is to select the 'Today' shortcut in the date control. Parsing the date format is for the code to perform the corresponding DOM element click.

[0068] In this embodiment, the usage scenarios of the date control are divided by two parameters, a total of three scenarios: the method scenario of selecting a specific date (date_select), the method scenario of selecting a shortcut key (date_btn_select), and the method scenario of inputting in the date control (date_input).

[0069] After analysis, the three scenarios have the following characteristics: when a specific date data is passed in, the selectable status is 'optional';

[0070] when a specific date data is passed in, the selectable status is 'not optional';

[0071] when a specific'shortcut key' name is passed in, the selectable status is 'optional'.

[0072] In this embodiment, it is judged by two parameters, the data type and the status. As Figure 2 shown, it can quickly identify the specific application scenario, and the above two parameters can cover possible operation scenarios.

[0073] More specifically, for the first operation scenario, that is, the date_select method scenario, the date data is determined by selecting the data in the date pop-up panel.

[0074] Different date types will generate different pop-up panels, and the corresponding positioning elements are also different. For example, the year type panel, the month type panel, and the year-month-day type panel; different masks, for the same type, will generate different formats of data, such as 2024-01-01, January 1, 2024; and for the same type and the same mask, different data will be generated according to different time zones.

[0075] By summarizing the possible data results, it can be found that date data with different masks and types can basically be divided into two types. One is that it contains numbers and characters, where the characters include special characters, Chinese characters, or / and English characters, such as 2024-01-01, 2024 year, 2024 / 12, 2025-04-11T08:04:31.55Z, etc. The other is that it only contains numbers, such as 20240101, 2024.

[0076] In summary, as Figure 3 shown, the data can be divided into pure numerical data and data with characters. For non-time zone data with different mask formats, if the special characters or Chinese characters in the data are removed, the results are the same, and the delimiter can be used as the basis for judgment. The lengths after removing special characters are different for different types. For example, the year type has a length of 4 digits, such as 2024, the year-month type has a length of 6 digits, such as 202412, the year-month-day type has a length of 8 digits, such as 20241217, and the year-month-day and time type has a length of 14 digits, such as 20241217092057.

[0077] Taking the above into comprehensive consideration, in this embodiment, the data in the test return result of the first operation scenario is split into an array of numerical types and an array of non-numerical types. The elements of the array of numerical types are concatenated into a complete character, the length of the complete character is judged, and the preliminary date type is judged according to the length of the complete character; the characters in the array of non-numerical types are extracted, and the preliminary date type is corrected according to the character type and quantity to obtain the final test return result.

[0078] If the length of the complete character is 4, it is considered as year type data. If the length of the complete character is 6, it is considered as year-month type data or time type data. If the length of the complete character is 8, it is considered as year-month-day type data. If the length of the complete character is 14, it is considered as year-month-day and time type data. If the length of the complete character is 16, it is considered as date range data or data with time zone.

[0079] If the length of the complete character is other lengths, it is considered as illegal data or error data, such as 202, 2023101108, etc.

[0080] The process of correcting the preliminary date type according to the character type and quantity includes that if the characters are the same delimiter, the number of delimiters exceeds one and the delimiter is not the predetermined delimiter. The predetermined delimiter in this embodiment is ":". Combining the preliminary date type, dividing the complete character from left to right according to the principle that the year occupies four digits, the month occupies two digits, and the day occupies two digits, and through mask formatting processing, the final test return result is obtained.

[0081] If the characters are different types of delimiters and contain a predetermined delimiter, in combination with the preliminary date type, divide the complete characters from left to right according to the principle that the year occupies four digits, the month occupies two digits, the day occupies two digits, the hour occupies two digits, the minute occupies two digits, and the second occupies two digits, and perform mask formatting processing to obtain the final test return result.

[0082] If the complete character of pure numbers is 20241217092057 and the delimiters are "-,-,:" then according to the above principle, the final test return result represents 2024-12-17 09:20:57.

[0083] If the complete character of pure numbers is 20241217092057 and the delimiters are " / , / ,:,:" then according to the above principle, the final test return result represents 2024 / 12 / 17 09:20:57.

[0084] The original data is UTC time: 2025-10-12T14:30:00Z, the complete character of pure numbers is 20251012143000, and the delimiters are "-,-,T,::,.,Z". Then according to the above principle, determine whether there is a predetermined delimiter "T" or "Z" or other delimiters representing time zones. If it is determined that there is, the final test return result combined with the user's client time zone (East Eighth District) is represented as 2025-10-12 22:30:00.

[0085] If the complete character of pure numbers is 2025041120250422 and the delimiters are " / , / ,-, / , / " then according to the above principle, determine whether there is a predetermined delimiter "T" or "Z" or other delimiters representing time zones. If it is determined that there is none, the final test return result is represented as 2025 / 04 / 12 – 2025 / 04 / 22.

[0086] Of course, the above recognition process can also be used in other scenarios or methods.

[0087] The second operation scenario, that is, the date_input method scenario, determines the date data by inputting data and only includes three behaviors: clicking on the control, inputting data, and losing focus.

[0088] The third operation scenario, that is, the date_btn_select method scenario, determines the date data by selecting a shortcut key. The shortcut keys include today, confirm, beginning of the month, beginning of the quarter, beginning of the year, beginning of the fiscal year, and end of the fiscal year, etc. After obtaining the corresponding elements, encapsulate them into a dictionary and trigger the corresponding click event.

[0089] This embodiment covers the date control from three dimensions of usage scenario, control type, and data type through two parameters and can handle all scenarios.

[0090] In addition, a double-check mechanism is added in this embodiment, namely the first check (also called value check) and the second check (also called style check), as Figure 4 shown.

[0091] This embodiment adopts a verification method that combines data and style to verify the correctness of data. The method parameters include actual data, expected selected data, and whether it meets the expectations.

[0092] Specifically, the value check includes whether the value selected by the control, the value input by the control, the value automatically corrected by the control, the value assigned to the control by the code, and the data with inconsistent time zone data selection results are consistent with the expected value;

[0093] The style check includes whether the control itself changes the selectable and unselectable states due to business logic linkage, whether data from the previous month or the next month cannot be selected in the control pop-up window, and whether the style or unselectable state where data of special dates cannot be selected is consistent with the expected value.

[0094] The final check is considered to pass only when both layers of checks pass.

[0095] First, it is the check of the value. According to the original data and the pre-configured date offset, calculate the original expected value. According to the time zone where the client to which the date control belongs is located, correct the original expected value, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first check passes. If they are inconsistent, determine whether the corrected expected value is correct. If it is correct, the first check fails, otherwise it passes.

[0096] Among them, the process of calculating the original expected value according to the original data and the pre-configured date offset includes: if the date offset is zero, use the original expected value as the expected value after introducing the date offset; if the date offset is greater than zero, use the value obtained by adding the date offset to the original expected value as the expected value after introducing the date offset; if the date offset is less than zero, use the value obtained by subtracting the date offset from the original expected value as the expected value after introducing the date offset.

[0097] Simply put, that is, according to the currently displayed value of the date control (or the date data of the setting operation), combined with the date offset in the scenario and the time zone of the client where the operation scenario is executed, dynamically calculate the expected value, and then verify it with the test return result.

[0098] The current display value of the date control (or the date data for the setting operation, which can also be called the value selected by the date control) can be obtained through front-end js code. The date offset in the test scenario can be set through a configuration file, and the time zone data can be obtained through a client function. With these three parameters, a dynamic expected value can be obtained instead of a fixed value. There are the following three cases for comparing the specific returned result with the expected value:

[0099] (1) The returned value is consistent with the expected value and meets the expectation;

[0100] (2) The returned value is inconsistent with the expected value but meets the expectation;

[0101] (3) The returned value is inconsistent with the expected value and does not meet the expectation.

[0102] It should be noted that the above-mentioned expected value and expectation in this embodiment do not refer to a single parameter.

[0103] There are many scenarios, such as test scenarios, where the business logic of some special dates needs to be tested, such as fiscal year settlement, closing accounts, etc. At this time, it is necessary to change the actual time to simulate the scenario, and a large date deviation will occur. Then the expected result cannot be the original expected value, but the value after introducing the offset date.

[0104] Taking a typical embodiment as an example, the value selected by the date control (i.e., the control display value in Figure 4 ) is April 10, 2025. The date offset in the scenario is +20 days, that is, the date control is extended by 20 days before performing the test operation. Without considering the client time zone, after the date control performs the operation, there is a test return result, that is, April 30, 2025.

[0105] Then, according to the process of calculating the original expected value based on the original data and the pre-configured date offset, the expected value is April 30, 2025, which is consistent with the returned value, and the verification passes. If the returned value is not April 30, 2025, the verification fails.

[0106] However, the value selected by the date control is April 11, 2025, and the date offset is +20 days, that is, the date control is extended by 20 days before performing the test operation. Without considering the client time zone, after the date control performs the operation, there is a test return result, that is, May 1, 2025. However, the expected value of introducing the offset calculated simply should be April 31, 2025.

[0107] Then the returned value is inconsistent with the calculated expected value. At this time, it is necessary to check whether the expected value of introducing the offset is correct. Obviously, the expected value of introducing the offset is illegal data and is incorrect. At this time, it is considered that the returned value passes the verification and meets the expectation.

[0108] On the other hand, it is easy to have a scenario where the client and the server are not in the same time zone for the data that rebounds after the user makes a selection. In this case, it is necessary to simulate the time zone where the user (i.e., the client) is located for operations. For example, if the server time zone is set to the eighth time zone east, but the operation is performed in the eighth time zone west, the rebounding data will be offset from the tester's time, and it will be very difficult to verify the expected result when testing the dynamically calculated date. The time zone data must include the year, month, day, hour, minute, second, and special characters. After operating the date control, the time zone where the operation is initiated can be identified, the original UTC timestamp can be recorded, and the new UTC can be calculated through the target time zone to ensure the verification of data correctness.

[0109] Therefore, after calculating the original expected value based on the original data and the pre-configured date offset, it is also necessary to correct the expected value introduced with the date offset according to the time zone where the client is located.

[0110] Then, it is necessary to determine whether the corrected expected value is correct, that is, to determine whether the corrected expected value is illegal data. If so, it is considered that the corrected expected value is incorrect, and it is necessary to determine whether the linkage result between the corrected expected value and the date data of the operated date control is correct. If not, it is considered that the corrected expected value is incorrect.

[0111] This can solve the situation where the calculated expected value is illegal data as shown in the above typical embodiments. At the same time, this solution can also verify whether the illegal data is correctly processed. For example, if February 30th is entered, will it be automatically corrected to February 29th or February 28th.

[0112] It can also verify whether the linkage result between different date controls in the user business logic is correct. For example, it is pre-configured that the contract effective date must be after the signing date, and the start date of the operation should be less than or equal to the end date, etc.

[0113] After the first verification passes, obtain the optional status of the test return result of the date control that has passed the first verification, and determine whether the optional status is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0114] That is, the user operation needs to be ensured to be correct due to business logic or operation control of special dates. For example, if certain dates cannot be selected, the corresponding date control pop-up window style should be in a non-selectable state.

[0115] The operation scenario comes from use case design, that is, the desired date data is obtained by operating the date control through UI automation. The selected value for the second verification is obtained by operating the date control, that is, the test return result of the date control. By comparing the styles of the two, the style verification can be completed.

[0116] In summary, in the previous date selection method, the passed selection parameters can be obtained, that is, selectable and unselectable. The key is to verify the unselectable state. The readonly or disabled attributes of HTML elements can be checked, the CSS styles (such as pointer-events) can be checked, and whether the input is blocked by the JavaScript event handler can be checked, etc. to verify whether the corresponding element is selectable.

[0117] There are four results in total:

[0118] (1) The selection method / operation scenario is "selectable", and the style of the test return result is "selectable";

[0119] (2) The selection method / operation scenario is "unselectable", and the style of the test return result is "unselectable"

[0120] (3) The selection method / operation scenario is "unselectable", and the style of the test return result is "selectable"

[0121] (4) The selection method / operation scenario is "selectable", and the style of the test return result is "unselectable".

[0122] The verification of the first and second results passes, while the verification of the third and fourth results fails.

[0123] In some scenarios, it is selectable in the date control, but it is set to be unselectable in the code. In this case, the operation scenario / input method will be executed. It can pass the value verification, but when it comes to the style verification, since it is set to be unselectable in the code and the return result is selectable, the verification will fail. Therefore, an additional step can be added, that is, to verify the expectation to determine whether the expectation meets the pre-setting. If so, the style verification is also considered to pass.

[0124] In some embodiments, the results of double verification can be represented by numerical values. For example, 1 represents passing the verification, and 0 represents failing the verification. In this way, the four states of 00, 01, 11, and 10 are used to represent the results of double verification, which is relatively simple and clear.

[0125] After both layers / two-fold verifications pass, it is considered that the corresponding automated test case passes, which ensures both data correctness and user experience.

[0126] Embodiment 2

[0127] A date control encapsulation system, as Figure 5 shown, includes:

[0128] A data acquisition module, configured to acquire test time data and the test return result of the date control in an operation scenario;

[0129] A double - layer verification module, configured to perform a first verification and a second verification on the test return result in sequence;

[0130] The process of the first verification is to calculate the original expected value according to the test time data and the pre - configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes; if not, determine whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes;

[0131] The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0132] The execution processes of the above - mentioned modules can refer to the process of this step in Embodiment 1, and will not be elaborated here.

[0133] It can be understood that the above - mentioned individual units / modules can be separately or all combined into one or several other units / modules to form, or some of them can be further split into multiple smaller units in terms of function to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of this application.

[0134] The above - mentioned modules of this system are divided based on logical functions. In actual applications, the function of one module can also be realized by multiple modules, or the functions of multiple modules can be realized by one module. For example, the double - layer verification module in this embodiment can include, in other embodiments:

[0135] An expected - value calculation module, configured to calculate the original expected value, calculate the original expected value according to the original data and the pre - configured date offset, and correct the expected value introduced with the date offset according to the time zone of the client;

[0136] A first judgment module, configured to determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes; if not, call the second judgment module;

[0137] A second judgment module, configured to determine whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes.

[0138] Similarly, in other embodiments of this application, this system can also include other units / modules. In actual applications, these functions can also be assisted by other units and can be realized through the cooperation of multiple units.

[0139] According to another embodiment of the present application, the system described in this embodiment can be constructed and the method of Embodiment 1 can be implemented by running a computer program (including program code) capable of executing the respective steps involved in the corresponding method described in Embodiment 1 on a general computing device such as a computer including processing elements and storage elements such as a Central Processing Unit (CPU), a Random Access Memory (RAM), and a Read-Only Memory (ROM). The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the above computing device through the computer-readable recording medium and run therein.

[0140] Embodiment 3

[0141] A computer-readable storage medium (Memory), which is a memory device in an electronic device and is used to store programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the electronic device and, of course, the extended storage medium supported by the electronic device. The computer-readable storage medium provides a storage space, and this storage space stores the processing system of the electronic device.

[0142] Moreover, one or more instructions suitable for being loaded and executed by the processor are also stored in this storage space, and these instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory; optionally, it can also be at least one computer-readable storage medium located far from the aforementioned processor.

[0143] In one embodiment, one or more instructions are stored in the computer-readable storage medium; the processor loads and executes one or more instructions stored in the computer-readable storage medium to implement the following process:

[0144] Obtain the test time data and the test return result of the date control in the operation scenario, and perform a first verification and a second verification on the test return result in sequence;

[0145] The process of the first verification is to calculate the original expected value according to the test time data and the pre-configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs is located, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes; if they are not consistent, determine whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes.

[0146] The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0147] Embodiment 4

[0148] An electronic device, such as Figure 6 shown, the electronic device includes a processor 1001, a communication interface 1002, and a computer-readable storage medium 1003. Among them, the processor 1001, the communication interface 1002, and the computer-readable storage medium 1003 can be connected through a bus or other means.

[0149] Among them, the communication interface 1002 is used to receive and send data. The computer-readable storage medium 1003 can be stored in the memory of the electronic device. The computer-readable storage medium 1003 is used to store a computer program. The computer program includes program instructions. The processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1003.

[0150] The processor 1001 (or CPU (Central Processing Unit, central processor)) is the computing core and control core of the electronic device, and is suitable for implementing one or more instructions. Specifically, it is suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function.

[0151] The processor 1001 is configured to execute the following process:

[0152] Obtain the test time data and the test return result of the date control in the operation scenario, and perform the first verification and the second verification on the test return result in sequence;

[0153] The process of the first verification is to calculate the original expected value according to the test time data and the pre-configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes. If they are not consistent, determine whether the corrected expected value is correct. If it is correct, the first verification fails; otherwise, it passes;

[0154] The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes; otherwise, the second verification fails.

[0155] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD - ROM , optical memory, etc.).

[0156] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0157] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0159] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made by those skilled in the art without creative efforts within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for encapsulating a date control, characterized in that, It includes the following steps: Obtain the test time data and the test return result of the date control in the operation scenario, and perform the first verification and the second verification on the test return result in sequence; The process of the first verification is to calculate the original expected value according to the test time data and the pre-configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs is located, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes. If they are not consistent, determine whether the corrected expected value is correct. If it is correct, the first verification fails, otherwise it passes; The process of the second verification is to determine whether the optional state of the test return result is consistent with the optional state of the operation scenario. If so, the second verification passes, otherwise the second verification fails; The process of calculating the original expected value according to the test time data and the pre-configured date offset includes: if the date offset is zero, use the original expected value as the expected value after introducing the date offset. If the date offset is greater than zero, use the value obtained by adding the date offset to the original expected value as the expected value after introducing the date offset. If the date offset is less than zero, use the value obtained by subtracting the date offset from the original expected value as the expected value after introducing the date offset.

2. The method for encapsulating a date control according to claim 1, characterized in that, The operation scenarios include: the first operation scenario, the second operation scenario, and the third operation scenario. Among them, if the type of data is date type and the optional state is optional, it is the first operation scenario. In the first operation scenario, the date data is determined by selecting the data in the date pop-up panel; If the type of data is date type and the optional state is non-optional, it is the second operation scenario. In the second operation scenario, the date data is determined by inputting data; If the type of data is non-date type and the optional state is optional, it is the third operation scenario. In the third operation scenario, the date data is determined by selecting a shortcut key; Determine the operation scenario according to the type and optional state of the test time data.

3. The encapsulation method of a date control according to claim 1, characterized in that The test return result of the date control in the operation scenario needs to be pre-processed. The pre-processing process includes: splitting the data in the test return result into an array of numeric types and an array of non-numeric types, concatenating the elements of the array of numeric types into a complete character, judging the length of the complete character, and judging the preliminary date type according to the length of the complete character; extracting the characters in the array of non-numeric types, correcting the preliminary date type according to the character type and quantity, and obtaining the final test return result through mask formatting processing.

4. The encapsulation method of a date control according to claim 3, wherein Judging the preliminary date type according to the length of the complete character includes: if the length of the complete character is 4, it is considered as year type data. If the length of the complete character is 6, it is considered as year-month type data or time type data. If the length of the complete character is 8, it is considered as year-month-day type data. If the length of the complete character is 14, it is considered as year-month-day and time type data. If the length of the complete character is 16, it is considered as date range data or data with time zone; If the length of the complete character is other lengths, it is considered illegal data or incorrect data.

5. The method for encapsulating a date control according to claim 3, wherein According to the character type and quantity, the process of correcting the preliminary date type includes that if the characters are the same separator, the number of separators exceeds one and the separator is not the predetermined separator, combining the preliminary date type, and dividing the complete character from left to right according to the principle that the year occupies four digits, the month occupies two digits, and the day occupies two digits, to obtain the final test return result; If the characters are different separators and include the predetermined separator, combining the preliminary date type, and dividing the complete character from left to right according to the principle that the year occupies four digits, the month occupies two digits, the day occupies two digits, the hour occupies two digits, the minute occupies two digits, and the second occupies two digits, to obtain the final test return result.

6. The encapsulation method of a date control according to claim 1, characterized in that, The process of determining whether the corrected expected value is correct includes: determining whether the corrected expected value is illegal data. If so, it is considered that the corrected expected value is incorrect. Determine whether the linkage result between the corrected expected value and the date data of the operation date control is correct. If not, it is considered that the corrected expected value is incorrect.

7. A date control encapsulation system, characterized in that, Including: A data acquisition module configured to acquire test time data and the test return result of the date control in the operation scenario; A double-layer verification module configured to perform a first verification and a second verification on the test return result in sequence; The process of the first verification is to calculate the original expected value according to the test time data and the pre-configured date offset, correct the original expected value according to the time zone where the client to which the date control belongs, and determine whether the test return result of the date control is consistent with the corrected expected value. If they are consistent, the first verification passes. If they are not consistent, determine whether the corrected expected value is correct. If it is correct, the first verification fails, otherwise it passes; The process of the second verification is to determine whether the optional status of the test return result is consistent with the optional status of the operation scenario. If so, the second verification passes, otherwise the second verification fails; The process of calculating the original expected value according to the test time data and the pre-configured date offset includes: if the date offset is zero, use the original expected value as the expected value after introducing the date offset. If the date offset is greater than zero, use the value obtained by adding the date offset to the original expected value as the expected value after introducing the date offset. If the date offset is less than zero, use the value obtained by subtracting the date offset from the original expected value as the expected value after introducing the date offset.

8. A computer-readable storage medium, characterized in that, For storing computer instructions, when the computer instructions are executed by a processor, the steps in the method according to any one of claims 1-6 are completed.

9. An electronic device, characterized in that, Including a memory, a processor, and computer instructions stored on the memory and running on the processor. When the computer instructions are run by the processor, the steps in the method according to any one of claims 1-6 are completed.

Citation Information

Patent Citations

  • Time control generation method and device, storage medium and electronic equipment

    CN118170357A

  • Satellite Radio Wave Receiving Device, Radio Controlled Timepiece, Method Of Outputting Date And Time Information, And Recording Medium

    CN107203127A

  • Verification method of NANDFlash controller empty page test method

    CN116185701A