Webpage data insertion method and device, computer equipment and storage medium
By displaying web page menus in browser web pages and generating multiple types of random data, the problem that existing tools cannot generate multiple types of random data is solved, and the diversity and efficiency of web page functional testing is improved.
Patent Information
- Application Number
- CN202411936833.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-25
AI Technical Summary
Existing tools have difficulty generating multiple types of random data in web functional testing, especially data types such as Chinese and special characters, which limits the diversity and efficiency of the test.
By obtaining the target form element that the user clicks in the browser web page, displaying the pre-registered web page menu, obtaining the data type selected by the user, and generating random data based on the type of predefined format rules, and finally inserting the data into the target form element.
Support for a variety of data types, including Chinese and special characters, improves the diversity and efficiency of data insertion and reduces the workload of manual input by users.
Smart Images

Figure CN119883255A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence and research and development technology, and in particular to a web page data insertion method, device, computer equipment and storage medium. Background Art
[0002] In the process of web page function testing, data entry is a crucial link. In order to simulate the behavior of real users and test the performance of web page forms under different data inputs, testers need to frequently enter various types of data in the form. Among them, the entry of random data is particularly critical because it can help testers cover more test scenarios and improve the comprehensiveness and accuracy of the test.
[0003] However, similar tools currently available on the market (such as browser plug-ins) have many deficiencies in random data entry. For example, when generating random data, many existing tools only support the random generation of English strings, but cannot generate random data containing Chinese. In addition, the types of random data that these tools can generate are relatively few. Most tools can only generate simple English strings, but cannot generate other types of random data such as numbers, dates, times, special characters, etc. This limitation forces testers to manually enter data when testing forms that require input of multiple data types, increasing the workload of testing.
[0004] Therefore, it is necessary to develop a random data entry tool to improve the diversity and efficiency of web page functional testing. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a web page data insertion method, apparatus, computer equipment and storage medium, which can improve the diversity and efficiency of random data entry during web page function testing.
[0006] In order to solve the above technical problems, the embodiment of the present application provides a web page data insertion method, which adopts the following technical solution:
[0007] Get the target form element clicked by the user in the browser web page;
[0008] Displaying a pre-registered webpage menu according to the target form element;
[0009] Obtaining the data type that needs to be inserted for the webpage menu determined by the user;
[0010] Acquire a predefined format rule according to the data type, and generate random data according to the format rule;
[0011] The random data is inserted into the target form element.
[0012] In order to solve the above technical problems, the embodiment of the present application further provides a web page data insertion device, which adopts the following technical solution:
[0013] The element acquisition module is used to acquire the target form element clicked by the user in the browser web page;
[0014] A menu display module, used to display a pre-registered webpage menu according to the target form element;
[0015] A type acquisition module, used to acquire the data type that needs to be inserted determined by the user for the webpage menu;
[0016] A data generation module, used to obtain a predefined format rule according to the data type, and generate random data according to the format rule;
[0017] A data insertion module is used to insert the random data into the target form element.
[0018] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, which adopts the technical solution described below: the computer device includes a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of the web page data insertion method as described in any one of the above when executing the computer-readable instructions.
[0019] In order to solve the above technical problems, an embodiment of the present application also provides a computer-readable storage medium, which adopts the following technical solution: the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the web page data insertion method as described in any one of the above items are implemented.
[0020] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0021] The embodiment of the present application obtains the target form element clicked by the user in the browser web page, accurately locates the specific position where the user wants to insert data, and avoids the misalignment of data insertion; by displaying the web page menu registered by the target form element and listing the various data types corresponding to the target form element for the user to flexibly choose, the user is provided with a variety of enterable data types, which significantly improves the diversity of data insertion; by obtaining the corresponding format rules according to the data type determined by the user and generating random data according to the format rules, the problem that the existing tools can only generate simple English strings is solved, and the demand for multiple data types for web page testing is met; by inserting the generated random data into the target form element, no manual operation by the user is required, and the efficiency of web page testing is further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0024] Figure 2 It is a flowchart of an embodiment of the webpage data insertion method of the present application;
[0025] Figure 3 It is a structural schematic diagram of an embodiment of a webpage data insertion device of the present application;
[0026] Figure 4 It is a structural diagram of an embodiment of a computer device of the present application. DETAILED DESCRIPTION
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0028] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0030] like Figure 1As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0031] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0032] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0033] The server 103 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal device 101 .
[0034] It should be noted that the web page data insertion method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the web page data insertion device is generally arranged in the server / terminal device.
[0035] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0036] Continue to refer Figure 2 , showing a flow chart of an embodiment of the question-answering method according to the present application. The webpage data insertion method comprises the following steps:
[0037] Step S201, obtaining the target form element clicked by the user in the browser webpage;
[0038] In this embodiment, the webpage data insertion method is executed on the electronic device (eg Figure 1 The server / terminal device shown in the figure can obtain the target form element clicked by the user in the browser webpage through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 2G / 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0039] Specifically, the method of obtaining the target form element clicked by the user in the browser webpage may be, for example, to pre-set a monitoring mechanism for the browser webpage to monitor the click event of the browser webpage. When the user browses the browser webpage on the computer side and right-clicks the target form element in the browser webpage, or when the user browses the browser webpage on the mobile phone side and manually clicks the target form element in the browser webpage, the preset monitoring mechanism monitors the click event on the browser webpage and records the target form element at the time of the click. The target form element may be an input box, a text box, etc.
[0040] Step S202, displaying a pre-registered webpage menu according to the target form element;
[0041] In this embodiment, a corresponding webpage menu is pre-registered for each form element in the browser webpage, so that when the user clicks any form element, a webpage menu corresponding to the form element is generated and displayed. The webpage menu may include one or more data type options that support insertion, such as "Insert mobile phone number", "Insert ID number", "Insert custom data" and other options.
[0042] Specifically, after obtaining the target form element clicked by the user in the browser web page, a web page menu corresponding to the target form element is generated and displayed according to the target form element. For example, when the target form element is a mobile phone number input box, the displayed web page menu may include an "Insert mobile phone number" option and an "Insert custom data" option; when the target form element is a name text box, the displayed web page menu may include an "Insert Chinese name" option.
[0043] In some optional implementations, before displaying the pre-registered webpage menu according to the target form element, the following steps may also be included:
[0044] Acquire a preset first configuration file, wherein the first configuration file includes first configuration information of a webpage menu to be registered;
[0045] Specifically, a pre-set first configuration file is obtained from a local file system or a remote server, wherein the first configuration file includes first configuration information of a web page menu to be registered, wherein the first configuration information may include menu name information, supported data type information, format rule information of each data type, and a callback function, wherein the callback function is used to generate random data for different format rules.
[0046] The first configuration file is passed to the browser, and the menu name, supported data types, format rules of each data type and a callback function for generating random data according to different format rules of the web page menu are registered according to the first configuration information to obtain a registered web page menu.
[0047] Specifically, the first configuration file obtained is passed to the browser, the first configuration file is parsed, and the first configuration information such as menu name information, supported data type information, format rule information of each data type, and callback function is extracted. The menu name in the web page menu is set according to the menu name information in the first configuration information, the data type options supported in the web page menu are created according to the supported data type information, the format rules of each data type are bound to the corresponding data type options, and the corresponding callback function is set. The callback function is used to generate corresponding random data for the format rule bound to the data type option when the user clicks on any data type option. After completing the above steps, the registered web page menu is obtained.
[0048] The embodiment of the present application configures supported data types and their format rules, as well as a callback function for generating random data in the first configuration information of the configuration file, and registers the data types supported by the web page menu, the format rules of each data type, and the callback function for generating random data according to different format rules according to the first configuration information, so that when the user clicks on any data type option, the corresponding random data can be generated according to the format rules bound to the data type option, thereby responding more quickly to the needs of different test scenarios for diversified data types, reducing the time for manual input and configuration, and improving test efficiency.
[0049] Step S203, obtaining the data type that needs to be inserted determined by the user for the webpage menu;
[0050] In this embodiment, when a user clicks on any data type option in a webpage menu, a preset monitoring mechanism is used to monitor the click event on the webpage menu, and the data type option at the time of the click is recorded. According to the data type option at the time of the click, the data type to be inserted determined by the user for the webpage menu is obtained. The data type may include but is not limited to Chinese name, mobile phone number, ID number, and custom data.
[0051] Step S204, obtaining a predefined format rule according to the data type, and generating random data according to the format rule;
[0052] In this embodiment, different format rules are defined in advance according to different data types. For example, the format rule of a Chinese name is composed of a surname and a given name; the format rule of a mobile phone number is composed of 11 digits, of which the first digit is 1, the second digit is a number between 3-9, and the remaining digits are between 0-9; the format rule of an ID number is composed of a 6-digit area code, an 8-digit date of birth, a 3-digit serial number, and a 1-digit check code; custom data can set corresponding custom format rules. According to the data type that the user needs to insert, the format rule corresponding to the data type is obtained, and random data is generated according to the format rule. For example, for a mobile phone number, it starts with 1, and the number segments are randomly selected in other positions to generate a random mobile phone number; for an ID number, the area code, date of birth, serial number, and check code are randomly selected in sequence to form a random ID number.
[0053] In some optional implementations, the generating of random data according to the format rule may include the following steps:
[0054] If the data type is a mobile phone number, the first digit of the mobile phone number is determined to be 1 according to the format rules of the mobile phone number;
[0055] Randomly select a first number from a preset first number range as the number at the second position of the mobile phone number;
[0056] Randomly select a number of second digits from a preset second data range as the digits in the remaining positions of the mobile phone number;
[0057] The first digit, the first digit and the plurality of second digits are combined to obtain a random mobile phone number.
[0058] Specifically, when the user determines that the inserted data type is a mobile phone number, the format rule of the mobile phone number is obtained. The format rule of the mobile phone number is composed of 11 digits, wherein the first digit is 1, the second digit is a digit within the first digit range, and the remaining digits are digits within the second data range. According to the format rule of the mobile phone number, the first digit of the mobile phone number is determined to be 1; a first digit is randomly selected from a preset first digit range as the digit in the second position of the mobile phone number, and the first data range can be 3-9; a number of second digits are randomly selected from a preset second data range as the digits in the remaining positions of the mobile phone number, and the second digit range can be 0-9, and the remaining positions are the third to eleventh digits. Afterwards, the first digit, the first digit, and the number of second digits are combined in order of position to obtain a random mobile phone number.
[0059] In some optional implementations, the generating of random data according to the format rule may include the following steps:
[0060] If the data type is a Chinese name, a predefined name library is obtained, wherein the name library includes a surname array and a given name array;
[0061] According to the format rules of Chinese names, a target surname is randomly selected from the surname array, a target name is randomly selected from the name array, and the target surname and the target name are combined to obtain a random Chinese name.
[0062] Specifically, when the user determines that the inserted data type is a Chinese name, a predefined name library is obtained, which includes a plurality of pre-collected surname arrays and given name arrays. The format rule of the Chinese name is obtained, and the format rule of the Chinese name is composed of a surname and a given name. A target surname is randomly selected from the surname array of the name library, and a target given name is randomly selected from the given name array of the name library. The obtained target surname and target given name are combined in the order of surname-given name to obtain a random Chinese name.
[0063] The embodiment of the present application introduces a predefined name library, randomly selects a target surname from the surname array of the name library according to the format rules of Chinese names, randomly selects a target name from the name array of the name library, and combines the target surname and the target name to obtain a random Chinese name, thereby solving the limitation that existing tools only support English strings when generating random data. Since it can automatically generate Chinese random data that meets the requirements, testers do not need to manually enter or modify data, thereby improving test efficiency.
[0064] In some optional implementations, the generating of random data according to the format rule may include the following steps:
[0065] If the data type is an ID card number, a predefined region code library is obtained, and a target region code is randomly selected from the region code library;
[0066] Randomly generate a target date of birth within the valid date range, and randomly generate a target serial number within the valid serial number range;
[0067] Calculate a target check code according to the target area code, the target date of birth, the target serial number and a preset weighting factor;
[0068] According to the format rules of the ID card number, the target area code, the target date of birth, the target serial number and the target check code are combined to obtain a random ID card number.
[0069] Specifically, when the user determines that the inserted data type is an ID card number, the format rule of the ID card number is obtained, and the format rule of the ID card number is composed of a 6-digit area code, an 8-digit date of birth, a 3-digit serial number and a 1-digit check code. A predefined area code library is obtained, and a 6-digit target area code is randomly selected from the area code library. An 8-digit target date of birth is randomly generated within the valid date range, and a 3-digit target serial number is randomly generated within the valid serial number range. The weighting factor is determined from a predefined weighting factor table, and a weighted operation and a modular operation are performed according to the target area code, the target date of birth, the target serial number and the weighting factor to obtain the target check code. The target area code, the target date of birth, the target serial number and the target check code are combined in the order set by the format rule of the ID card number to obtain a random ID card number.
[0070] In some optional implementations, the generating of random data according to the format rule may include the following steps:
[0071] If the data type is custom data, obtaining a predefined random number list, and randomly selecting target custom data from the random number list;
[0072] Using the format rules of the custom data, verifying whether the target custom data meets the format requirements;
[0073] If the target user-defined data meets the format requirement, the target user-defined data is output as random user-defined data.
[0074] Specifically, when the user determines that the inserted data type is custom data, a predefined random number list is obtained, which contains several pre-entered custom data, and the custom data can be numbers, symbols, character strings, text, etc., and the target custom data is randomly selected from the random number list. The format rules of the custom data are obtained, and the format rules of the custom data can include format requirements such as data length, character type, and restrictions on special characters; the format rules of the custom data are used to verify whether the target custom data meets the format requirements. When the target custom data meets the format requirements, the target custom data is output as random custom data.
[0075] The embodiment of the present application predefines a random number list and selects and verifies the target custom data according to the format rules of the custom data. It can not only support simple data types (such as strings, numbers, etc.), but also support complex custom data types (such as strings of specific lengths, etc.), so that testers can customize the range and format of random data according to specific test requirements, thereby generating random data that is more suitable for the test scenario.
[0076] In some optional implementations, if the data type is custom data, before obtaining the predefined random number list, the following steps may also be included:
[0077] Acquire a preset second configuration file, where the second configuration file includes second configuration information of the sidebar page of the browser;
[0078] Specifically, a pre-set second configuration file is obtained from a local file system or a remote server, and the second configuration file includes second configuration information of a sidebar page of a browser, wherein the sidebar page is an interface for a user to enter a random number list. On a computer side, the sidebar page can be displayed on the left or right side of a browser webpage; on a mobile phone side, the sidebar page can be displayed below the browser webpage; the second configuration information may include page layout, style and position of a data entry area, etc.
[0079] A data entry area of the sidebar page is created according to the second configuration information, wherein the data entry area is used for the user to enter a random number list, thereby obtaining the created sidebar page.
[0080] Specifically, the second configuration information is parsed to extract the page layout, the style and position of the data entry area. A sidebar page of the browser is created according to the extracted page layout; a data entry area is created in the sidebar page according to the style and position of the data entry area, and the data entry area includes controls such as a data input box and a data save button for the user to enter a random number list. After completing the above steps, the created sidebar page is obtained.
[0081] The embodiment of the present application allows the tester to customize the configuration information of the sidebar page as needed, including the location, size, style, etc. of the data entry area, through the second configuration file, so that the sidebar page can flexibly adapt to different testing requirements. By integrating the data entry area into the sidebar page of the browser, seamless integration between the testing tool and the browser is achieved, so that the tester can directly use the data entry area of the sidebar page in the browser environment without switching to other tools or interfaces, which helps to maintain the continuity and fluency of the testing process and improve the testing efficiency.
[0082] Step S205: inserting the random data into the target form element.
[0083] In this embodiment, the generated random data is inserted into the target form element. For example, JavaScript may be used to modify the value attribute or innerHTML attribute of the target form element to set the random data as the value of the target form element, thereby implementing the insertion of the random data.
[0084] The embodiment of the present application adopts the above scheme, specifically by obtaining the target form element clicked by the user in the browser web page, accurately locating the specific position where the user wants to insert data, thereby avoiding misalignment of data insertion; by displaying the web page menu registered by the target form element and listing the various data types corresponding to the target form element for the user to flexibly choose, the user is provided with a variety of enterable data types, which significantly improves the diversity of data insertion; by obtaining the corresponding format rules according to the data type determined by the user, and generating random data according to the format rules, the problem that the existing tools can only generate simple English strings is solved, and the demand for multiple data types for web page testing is met; by inserting the generated random data into the target form element, no manual operation by the user is required, thereby further improving the efficiency of web page testing.
[0085] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target form elements, web page menus, random data and other information as well as other related data, the above-mentioned target form elements, web page menus, random data and other information as well as other related data can also be stored in a blockchain node.
[0086] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0087] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The above-mentioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0088] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0089] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a web page data insertion device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0090] like Figure 3 As shown, the webpage data insertion device 400 described in this embodiment includes: an element acquisition module 401, a menu display module 402, a type acquisition module 403, a data generation module 404 and a data insertion module 405. Among them:
[0091] The element acquisition module 401 is used to acquire the target form element clicked by the user in the browser webpage;
[0092] The menu display module 402 is used to display the pre-registered webpage menu according to the target form element;
[0093] The type acquisition module 403 is used to acquire the data type that needs to be inserted determined by the user for the webpage menu;
[0094] A data generation module 404 is used to obtain a predefined format rule according to the data type and generate random data according to the format rule;
[0095] The data inserting module 405 is used to insert the random data into the target form element.
[0096] In this embodiment, the element acquisition module 401 is used to acquire the target form element clicked by the user in the browser webpage. For example, a monitoring mechanism can be set in advance for the browser webpage to monitor the click event of the browser webpage. When the user browses the browser webpage on the computer side and clicks the target form element in the browser webpage by right-clicking the mouse, or when the user browses the browser webpage on the mobile phone side and manually clicks the target form element in the browser webpage, the click event on the browser webpage is monitored through the preset monitoring mechanism, and the target form element at the time of the click is recorded. Among them, the target form element can be an input box, a text box, etc.
[0097] Specifically, the menu display module 402 is used to pre-register the corresponding web page menu for each form element in the browser web page, so that when the user clicks on any form element, the web page menu corresponding to the form element is generated and displayed. The web page menu may include one or more data type options that support insertion, such as "Insert mobile phone number", "Insert ID number", "Insert custom data" and other options. After obtaining the target form element clicked by the user in the browser web page, the web page menu corresponding to the target form element is generated and displayed according to the target form element. For example, when the target form element is a mobile phone number input box, the displayed web page menu may include the "Insert mobile phone number" option and the "Insert custom data" option; when the target form element is a name text box, the displayed web page menu may include the "Insert Chinese name" option.
[0098] Specifically, the type acquisition module 403 is used to monitor the click event on the webpage menu through a preset monitoring mechanism when the user clicks any data type option in the webpage menu, and record the data type option at the time of the click. According to the data type option at the time of the click, the data type determined by the user to be inserted into the webpage menu is obtained. The data type may include but is not limited to Chinese name, mobile phone number, ID number and custom data.
[0099] Specifically, the data generation module 404 is used to predefine different format rules according to different data types. For example, the format rule of a Chinese name is composed of a surname and a given name; the format rule of a mobile phone number is composed of 11 digits, wherein the first digit is 1, the second digit is a number between 3-9, and the remaining digits are between 0-9; the format rule of an ID number is composed of a 6-digit area code, an 8-digit date of birth, a 3-digit serial number, and a 1-digit check code; custom data can set corresponding custom format rules. According to the data type that the user needs to insert, the format rule corresponding to the data type is obtained, and random data is generated according to the format rule. For example, for a mobile phone number, it starts with 1, and the number segments are randomly selected in other positions to generate a random mobile phone number; for an ID number, the area code, date of birth, serial number, and check code are randomly selected in sequence to form a random ID number.
[0100] Specifically, the data insertion module 405 is used to insert the generated random data into the target form element. For example, JavaScript may be used to modify the value attribute or innerHTML attribute of the target form element to set the random data as the value of the target form element to implement the insertion of the random data.
[0101] The web page data insertion device 400 of the embodiment of the present application obtains the target form element clicked by the user in the browser web page, accurately locates the specific position where the user wants to insert data, and avoids the misalignment of data insertion; by displaying the web page menu registered by the target form element and listing the various data types corresponding to the target form element for the user to flexibly choose, the user is provided with a variety of enterable data types, which significantly improves the diversity of data insertion; by obtaining the corresponding format rules according to the data type determined by the user and generating random data according to the format rules, the problem that the existing tools can only generate simple English strings is solved, and the demand for multiple data types for web page testing is met; by inserting the generated random data into the target form element, no manual operation by the user is required, and the efficiency of web page testing is further improved.
[0102] In some optional implementations of this embodiment, the webpage data inserting device 400 may further include a first configuration module and a menu registration module.
[0103] A first configuration module, used to obtain a preset first configuration file, wherein the first configuration file includes first configuration information of a webpage menu to be registered;
[0104] The menu registration module is used to transfer the first configuration file to the browser, register the menu name of the web page menu, the supported data types, the format rules of each data type and the callback function for generating random data according to different format rules according to the first configuration information, and obtain the registered web page menu.
[0105] Specifically, the first configuration module is used to obtain a pre-set first configuration file from a local file system or a remote server, wherein the first configuration file includes first configuration information of a web page menu to be registered, wherein the first configuration information may include menu name information, supported data type information, format rule information of each data type, and a callback function, wherein the callback function is used to generate random data for different format rules.
[0106] Specifically, the menu registration module is used to pass the acquired first configuration file to the browser, parse the first configuration file, and extract the first configuration information such as menu name information, supported data type information, format rule information of each data type, and callback function. The menu name in the webpage menu is set according to the menu name information in the first configuration information, the data type options supported in the webpage menu are created according to the supported data type information, the format rules of each data type are bound to the corresponding data type options, and the corresponding callback function is set. The callback function is used to generate corresponding random data for the format rule bound to the data type option when the user clicks on any data type option. After completing the above steps, the registered webpage menu is obtained.
[0107] The web page data insertion device 400 of the embodiment of the present application configures the supported data types and their format rules, as well as a callback function for generating random data in the first configuration information of the configuration file, and registers the data types supported by the web page menu, the format rules of each data type, and the callback function for generating random data according to different format rules according to the first configuration information, so that when the user clicks on any data type option, the corresponding random data can be generated according to the format rules bound to the data type option, thereby responding more quickly to the needs of different test scenarios for diversified data types, reducing the time for manual input and configuration, and improving test efficiency.
[0108] In some optional implementations of this embodiment, the data generation module 404 may include a first selection submodule, a second selection submodule, a third selection submodule and a number combination submodule.
[0109] A first selection submodule is used for determining the first digit of the mobile phone number as 1 according to the format rule of the mobile phone number if the data type is a mobile phone number;
[0110] A second selection submodule is used to randomly select a first number from a preset first number range as the number at the second position of the mobile phone number;
[0111] A third selection submodule is used to randomly select a number of second digits from a preset second data range as the digits in the remaining positions of the mobile phone number;
[0112] The number combination submodule is used to combine the first digit, the first digit and the plurality of second digits to obtain a random mobile phone number.
[0113] Specifically, the first selection submodule is used to obtain the format rules of the mobile phone number when the user determines that the inserted data type is a mobile phone number. The format rules of the mobile phone number are composed of 11 numbers, wherein the first digit is 1, the second digit is a number within the first digit range, and the remaining digits are numbers within the second data range. According to the format rules of the mobile phone number, the first digit of the mobile phone number is determined to be 1. The second selection submodule is used to randomly select a first digit from a preset first digit range as the digit in the second position of the mobile phone number, and the first data range can be 3-9. The third selection submodule is used to randomly select a number of second digits from a preset second data range as the digits in the remaining positions of the mobile phone number, and the second digit range can be 0-9, and the remaining positions are the third to eleventh digits. Afterwards, the number combination submodule is used to combine the first digit, the first digit and a number of second digits in the order of position to obtain a random mobile phone number.
[0114] In some optional implementations of this embodiment, the data generation module 404 may include a name library acquisition submodule and a name combination submodule.
[0115] A name library acquisition submodule, used for acquiring a predefined name library if the data type is a Chinese name, the name library including a surname array and a given name array;
[0116] The name combination submodule is used to randomly select a target surname from the surname array and a target name from the name array according to the format rules of the Chinese name, and to combine the target surname and the target name to obtain a random Chinese name.
[0117] Specifically, the name library acquisition submodule is used to acquire a predefined name library when the user determines that the inserted data type is a Chinese name. The name library includes a plurality of pre-collected surname arrays and given name arrays. The name combination submodule is used to acquire the format rule of the Chinese name. The format rule of the Chinese name is composed of a surname and a given name. A target surname is randomly selected from the surname array of the name library, and a target given name is randomly selected from the given name array of the name library. The acquired target surname and target given name are combined in the order of surname-given name to obtain a random Chinese name.
[0118] The data generation module 404 of the embodiment of the present application introduces a predefined name library, randomly selects a target surname from the surname array of the name library according to the format rules of Chinese names, randomly selects a target name from the name array of the name library, and combines the target surname and the target name to obtain a random Chinese name, thereby solving the limitation that existing tools only support English strings when generating random data. Since it can automatically generate Chinese random data that meets the requirements, testers do not need to manually enter or modify data, thereby improving test efficiency.
[0119] In some optional implementations of this embodiment, the data generation module 404 may include a code selection submodule, a random generation submodule, a check code calculation submodule, and an ID number combination submodule.
[0120] A code selection submodule, for obtaining a predefined region code library if the data type is an identity card number, and randomly selecting a target region code from the region code library;
[0121] The random generation submodule is used to randomly generate a target date of birth within a valid date range and a target serial number within a valid serial number range;
[0122] A check code calculation submodule, used to calculate a target check code according to the target area code, the target date of birth, the target serial number and a preset weighting factor;
[0123] The ID number combination submodule is used to combine the target area code, the target date of birth, the target serial number and the target check code according to the format rules of the ID number to obtain a random ID number.
[0124] Specifically, the code selection submodule is used to obtain the format rules of the ID card number when the user determines that the inserted data type is an ID card number. The format rules of the ID card number are composed of a 6-digit area code, an 8-digit date of birth, a 3-digit serial number and a 1-digit check code. A predefined area code library is obtained, and a 6-digit target area code is randomly selected from the area code library. The random generation submodule is used to randomly generate an 8-digit target date of birth within the valid date range, and randomly generate a 3-digit target serial number within the valid serial number range. The check code calculation submodule is used to determine the weighting factor from the predefined weighting factor table, and perform weighted operations and modular operations according to the target area code, target date of birth, target serial number and weighting factor to obtain the target check code. The ID card number combination submodule is used to combine the target area code, target date of birth, target serial number and target check code in the order set by the format rules of the ID card number to obtain a random ID card number.
[0125] In some optional implementations of this embodiment, the data generation module 404 may include a list acquisition submodule, a format verification submodule and a data output submodule.
[0126] A list acquisition submodule, for acquiring a predefined random number list if the data type is custom data, and randomly selecting target custom data from the random number list;
[0127] A format verification submodule, used to verify whether the target custom data meets the format requirements by using the format rules of the custom data;
[0128] The data output submodule is used to output the target custom data as random custom data if the target custom data meets the format requirement.
[0129] Specifically, the list acquisition submodule is used to obtain a predefined random number list when the user determines that the inserted data type is custom data. The random number list contains several pre-entered custom data, which can be numbers, symbols, strings, and text, etc., and randomly select the target custom data from the random number list. The format verification submodule is used to obtain the format rules of the custom data, which can include format requirements such as data length, character type, and restrictions on special characters; the format rules of the custom data are used to verify whether the target custom data meets the format requirements. The data output submodule is used to output the target custom data as random custom data when the target custom data meets the format requirements.
[0130] The data generation module 404 of the embodiment of the present application, by predefining a list of random numbers and selecting and verifying target custom data according to the format rules of custom data, can not only support simple data types (such as strings, numbers, etc.), but also support complex custom data types (such as strings of specific lengths, etc.), so that testers can customize the range and format of random data according to specific test requirements, thereby generating random data that is more suitable for the test scenario.
[0131] In some optional implementations of this embodiment, the webpage data inserting device 400 may include a second configuration module and a page creation module.
[0132] A second configuration module, used to obtain a preset second configuration file, where the second configuration file includes second configuration information of the sidebar page of the browser;
[0133] A page creation module is used to create a data entry area of the sidebar page according to the second configuration information, wherein the data entry area is used for the user to enter a random number list to obtain the created sidebar page.
[0134] Specifically, the second configuration module is used to obtain a preset second configuration file from a local file system or a remote server, and the second configuration file includes second configuration information of the sidebar page of the browser, wherein the sidebar page is an interface for users to enter a random number list. On a computer side, the sidebar page can be displayed on the left or right side of the browser webpage; on a mobile phone side, the sidebar page can be displayed below the browser webpage; the second configuration information may include page layout, style and position of the data entry area, etc.
[0135] Specifically, the page creation module is used to parse the acquired second configuration information to extract the page layout, the style and position of the data entry area. The sidebar page of the browser is created according to the extracted page layout; according to the style and position of the data entry area, a data entry area is created in the sidebar page, and the data entry area includes controls such as a data input box and a data save button for the user to enter a random number list. After completing the above steps, the created sidebar page is obtained.
[0136] The web page data insertion device 400 of the embodiment of the present application allows the tester to customize the configuration information of the sidebar page as needed, including the location, size, style, etc. of the data entry area, through the second configuration file, so that the sidebar page can flexibly adapt to different testing requirements. By integrating the data entry area into the sidebar page of the browser, seamless integration between the testing tool and the browser is achieved, so that the tester can directly use the data entry area of the sidebar page in the browser environment without switching to other tools or interfaces, which helps to maintain the continuity and fluency of the testing process and improve the testing efficiency.
[0137] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0138] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 6 with a memory 61, a processor 62, and a network interface 63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0139] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0140] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as computer-readable instructions of the web page data insertion method, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.
[0141] The processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip in some embodiments. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run the computer-readable instructions stored in the memory 61 or process data, such as running the computer-readable instructions of the webpage data insertion method.
[0142] The network interface 63 may include a wireless network interface or a wired network interface. The network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.
[0143] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the web page data insertion method as described above.
[0144] The computer device, computer-readable storage medium and computer-readable instructions provided in the embodiments of the present application can obtain the target form element clicked by the user in the browser web page through the processor execution, accurately locate the specific position where the user wants to insert data, and avoid the misalignment of data insertion; by displaying the web page menu registered by the target form element and listing the various data types corresponding to the target form element for the user to flexibly choose, the user is provided with a variety of enterable data types, which significantly improves the diversity of data insertion; by obtaining the corresponding format rules according to the data type determined by the user and generating random data according to the format rules, the problem that the existing tools can only generate simple English strings is solved, and the demand for multiple data types for web page testing is met; by inserting the generated random data into the target form element, no manual operation by the user is required, and the efficiency of web page testing is further improved.
[0145] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0146] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to replace some of the technical features therein with equivalents. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
[0147] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
Claims
1. A web page data insertion method, characterized in that: The steps include: Get the target form element clicked by the user in the browser web page; Displaying a pre-registered webpage menu according to the target form element; Obtaining the data type that needs to be inserted for the webpage menu determined by the user; Acquire a predefined format rule according to the data type, and generate random data according to the format rule; The random data is inserted into the target form element.
2. The web page data insertion method according to claim 1, characterized in that: Before the step of displaying the pre-registered webpage menu according to the target form element, the method further includes: Acquire a preset first configuration file, wherein the first configuration file includes first configuration information of a webpage menu to be registered; The first configuration file is passed to the browser, and the menu name, supported data types, format rules of each data type and a callback function for generating random data according to different format rules of the web page menu are registered according to the first configuration information to obtain a registered web page menu.
3. The web page data insertion method according to claim 1, characterized in that: The step of generating random data according to the format rule comprises: If the data type is a mobile phone number, the first digit of the mobile phone number is determined to be 1 according to the format rules of the mobile phone number; Randomly select a first number from a preset first number range as the number at the second position of the mobile phone number; Randomly select a number of second digits from a preset second data range as the digits in the remaining positions of the mobile phone number; The first digit, the first digit and the plurality of second digits are combined to obtain a random mobile phone number.
4. The web page data insertion method according to claim 1, characterized in that: The step of generating random data according to the format rule comprises: If the data type is a Chinese name, a predefined name library is obtained, wherein the name library includes a surname array and a given name array; According to the format rules of Chinese names, a target surname is randomly selected from the surname array, a target name is randomly selected from the name array, and the target surname and the target name are combined to obtain a random Chinese name.
5. The web page data insertion method according to claim 1, characterized in that: The step of generating random data according to the format rule comprises: If the data type is an ID card number, a predefined region code library is obtained, and a target region code is randomly selected from the region code library; Randomly generate a target date of birth within the valid date range, and randomly generate a target serial number within the valid serial number range; Calculate a target check code according to the target area code, the target date of birth, the target serial number and a preset weighting factor; According to the format rules of the ID card number, the target area code, the target date of birth, the target serial number and the target check code are combined to obtain a random ID card number.
6. The webpage data insertion method according to claim 1, characterized in that: The step of generating random data according to the format rule comprises: If the data type is custom data, obtaining a predefined random number list, and randomly selecting target custom data from the random number list; Using the format rules of the custom data, verifying whether the target custom data meets the format requirements; If the target user-defined data meets the format requirement, the target user-defined data is output as random user-defined data.
7. The webpage data insertion method according to claim 6, characterized in that: If the data type is custom data, before the step of obtaining a predefined random number list, the method further includes: Acquire a preset second configuration file, where the second configuration file includes second configuration information of the sidebar page of the browser; A data entry area of the sidebar page is created according to the second configuration information, wherein the data entry area is used for the user to enter a random number list, thereby obtaining the created sidebar page.
8. A web page data insertion device, characterized in that: The device comprises: The element acquisition module is used to acquire the target form element clicked by the user in the browser web page; A menu display module, used to display a pre-registered webpage menu according to the target form element; A type acquisition module, used to acquire the data type that needs to be inserted determined by the user for the webpage menu; A data generation module, used to obtain a predefined format rule according to the data type, and generate random data according to the format rule; A data insertion module is used to insert the random data into the target form element.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the web page data insertion method as claimed in any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the web page data insertion method according to any one of claims 1 to 7 are implemented.