Element positioning method and system based on browser front-end image recognition
Through image recognition technology based on the browser front-end, combined with machine learning algorithms and web page DOM structure, it solves the problem of accurate positioning of traditional element positioning methods in complex web pages, achieves higher positioning accuracy and stability, and is suitable for dynamic changes. page.
Patent Information
- Application Number
- CN202410761288.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-10-01
AI Technical Summary
Traditional browser front-end element positioning methods have accurate positioning challenges in complex web page structures or dynamically changing pages, which are difficult to effectively solve.
Using image recognition technology based on the browser front-end, through the steps of data collection, model training, image recognition, element positioning, positioning result verification and positioning result correction, machine learning algorithms such as convolutional neural networks or support vector machines are used, combined with the web page The DOM structure enables accurate positioning of elements.
It improves the reliability and accuracy of element positioning, reduces operational errors, enhances the stability and reliability of the system, and collects diverse and high-quality sample data through web crawler technology to support the verification and correction of positioning results.
Smart Images

Figure CN118735993A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology, and in particular to an element positioning method and system based on browser front-end image recognition. Background Art
[0002] In current Internet applications, element positioning in the browser front end is an important technical requirement. Traditional element positioning methods mainly rely on HTML tag attributes for positioning, but for some complex web page structures or dynamically changing pages, traditional methods may face some challenges. Summary of the invention
[0003] To solve the above problems, the present invention provides an element positioning method and system based on browser front-end image recognition, which achieves accurate positioning of web page elements by utilizing image recognition technology, thereby improving the reliability and accuracy of positioning.
[0004] To achieve the above object, the technical solution adopted by the present invention is:
[0005] A method for locating elements based on browser front-end image recognition comprises the following steps:
[0006] Data collection: Collect a set of web page element image samples of different types and states;
[0007] Model training: Based on the collected web page element image samples, use machine learning algorithms to train an image recognition model;
[0008] Image recognition: By comparing web page screenshots with trained image recognition models, image recognition of web page elements is achieved;
[0009] Element positioning: Element positioning is performed based on the recognized image information and the DOM structure of the web page.
[0010] Furthermore, the element positioning method based on browser front-end image recognition also includes the following steps:
[0011] Positioning result verification: verify the positioned elements;
[0012] Correction of positioning results: If errors or inaccuracies occur during the element positioning process, the positioning accuracy can be improved by adjusting the parameters of the image recognition model or re-collecting and training samples.
[0013] Furthermore, the machine learning algorithm is a convolutional neural network algorithm or a support vector machine algorithm.
[0014] Furthermore, the step of collecting a group of web page element image samples of different types and different states specifically includes:
[0015] Representative web page element image samples are collected through web crawler technology. Specifically, when crawling web pages, elements of different types and states are selected and their screenshots are saved as sample data.
[0016] Further, different types of elements include buttons, input boxes, and text.
[0017] Furthermore, the step of realizing image recognition of web page elements by comparing the web page screenshot with the trained image recognition model specifically includes:
[0018] Based on existing browser extensions or self-developed tools, the screenshots are passed to the trained image recognition model for recognition and the recognition results are output;
[0019] The type and status of the element are determined by comparing the results output by the image recognition model.
[0020] Furthermore, the step of verifying the located element specifically includes:
[0021] Check the attribute information of the element;
[0022] Compare the element's attribute information with the expected result.
[0023] If the attribute information of the element is consistent with the expected result, it means that the element is positioned accurately; if not, it means that the element is positioned inaccurately.
[0024] Furthermore, the attribute information of the element includes the text content and link address of the inspection element.
[0025] A system for locating elements based on browser front-end image recognition, wherein the system for locating elements based on browser front-end image recognition is used to execute the method for locating elements based on browser front-end image recognition as described above.
[0026] Furthermore, the element positioning system based on browser front-end image recognition includes:
[0027] A data collection module, used for collecting a set of web page element image samples including different types and different states;
[0028] A model training module is used to train an image recognition model using a machine learning algorithm based on the collected web page element image samples;
[0029] An image recognition module is used to realize image recognition of web page elements by comparing web page screenshots with the trained image recognition model;
[0030] An element positioning module is used to locate elements based on the identified image information and the DOM structure of the web page;
[0031] Positioning result verification module, used to verify the positioned elements;
[0032] The positioning result correction module is used to improve the positioning accuracy by adjusting the parameters of the image recognition model or re-collecting and training samples when errors or inaccuracies occur during the element positioning process.
[0033] The beneficial effects of the present invention are:
[0034] 1. The present invention can provide a diversified data set by collecting a group of web page element image samples of different types and different states, so that model training is more comprehensive and accurate. By using a machine learning algorithm to train the collected web page element image samples, a model that can be used for image recognition can be established. This model can learn the characteristics and discrimination of different elements, thereby improving the accuracy of image recognition. By comparing the web page screenshot with the trained image recognition model, the image recognition of the web page elements can be realized. In this way, the elements that need to be operated can be automatically located and identified in the web page. By locating the elements through the identified image information and combining the DOM structure of the web page, the elements that need to be operated can be accurately located. This can improve the user experience and reduce the error of the operation. The located elements can be verified to ensure the accuracy of the positioning. Through verification, it can be determined whether the positioning is correct, thereby further improving the reliability and stability of the system. When errors or inaccuracies occur in the element positioning process, the positioning results can be corrected by adjusting the parameters of the image recognition model or re-collecting and training samples. In this way, the accuracy and stability of the positioning can be improved, and the performance of the system can be further optimized. In summary, the element positioning method based on browser front-end image recognition can achieve precise positioning and operation of web page elements through the steps of data collection, model training, image recognition, element positioning, positioning result verification and positioning result correction, thereby improving the accuracy and stability of the system.
[0035] 2. The present invention can collect representative web page element image samples by using web crawler technology. These samples come from elements of different types and different states, including buttons, input boxes and texts. Such diversity can effectively cover various common web page elements, thereby providing more comprehensive training data. By using crawler technology, elements of different types and states can be flexibly selected and collected. This means that the sample library can be continuously expanded according to actual needs, so that it has better adaptability and generalization ability. At the same time, crawler technology can also automatically collect data, reducing the workload of manual collection. By saving screenshots of elements as sample data, the quality of data can be guaranteed to a certain extent. Screenshots can provide accurate and repeatable image information, avoiding the problem of sample inconsistency caused by factors such as web page layout. This is very important for subsequent data processing and model training. In general, the technical effect of collecting a group of web page element image samples including different types and different states is to provide diversified, scalable and high-quality sample data, which provides a good foundation for subsequent technical research and application.
[0036] 3. The present invention can improve the accuracy of positioning, reduce the occurrence of erroneous operations, and increase the stability and reliability of the system by verifying the elements. At the same time, it can also help developers to find and fix positioning errors in time, and improve the quality and efficiency of the software. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of the element positioning method based on browser front-end image recognition of the present invention. DETAILED DESCRIPTION
[0038] See also Figure 1 As shown, the present invention provides an element positioning method and system based on browser front-end image recognition, which realizes accurate positioning of web page elements by utilizing image recognition technology, thereby improving the reliability and accuracy of positioning.
[0039] Example 1
[0040] A method for locating elements based on browser front-end image recognition comprises the following steps:
[0041] Data collection: Collect a set of web page element image samples of different types and states;
[0042] Model training: Based on the collected web page element image samples, an image recognition model is trained using a machine learning algorithm; further, the machine learning algorithm is a convolutional neural network algorithm or a support vector machine algorithm.
[0043] Image recognition: By comparing web page screenshots with trained image recognition models, image recognition of web page elements is achieved;
[0044] Element positioning: Based on the identified image information, elements are positioned in combination with the DOM structure of the web page;
[0045] Positioning result verification: verify the positioned elements;
[0046] Correction of positioning results: If errors or inaccuracies occur during the element positioning process, the positioning accuracy can be improved by adjusting the parameters of the image recognition model or re-collecting and training samples.
[0047] In the above scheme, by collecting a set of web page element image samples of different types and different states, a diversified data set can be provided, making the model training more comprehensive and accurate. By using a machine learning algorithm to train the collected web page element image samples, a model that can be used for image recognition can be established. This model can learn the characteristics and discrimination of different elements, thereby improving the accuracy of image recognition. By comparing the web page screenshot with the trained image recognition model, the image recognition of the web page elements can be realized. In this way, the elements that need to be operated can be automatically located and identified in the web page. By locating the elements by combining the identified image information with the DOM structure of the web page, the elements that need to be operated can be accurately located. This can improve the user experience and reduce the error of the operation. The located elements can be verified to ensure the accuracy of the positioning. Through verification, it can be determined whether the positioning is correct, thereby further improving the reliability and stability of the system. When errors or inaccuracies occur in the element positioning process, the positioning results can be corrected by adjusting the parameters of the image recognition model or re-collecting and training samples. In this way, the accuracy and stability of positioning can be improved, and the performance of the system can be further optimized. In summary, the element positioning method based on browser front-end image recognition can achieve precise positioning and operation of web page elements through the steps of data collection, model training, image recognition, element positioning, positioning result verification and positioning result correction, thereby improving the accuracy and stability of the system.
[0048] Furthermore, the step of collecting a group of web page element image samples of different types and different states specifically includes:
[0049] Representative web page element image samples are collected through web crawler technology. Specifically, when crawling web pages, elements of different types and states are selected and their screenshots are saved as sample data.
[0050] Among them, different types of elements include buttons, input boxes, and text.
[0051] In this embodiment, by using web crawler technology, representative web page element image samples can be collected. These samples come from elements of different types and different states, including buttons, input boxes and texts. Such diversity can effectively cover various common web page elements, thereby providing more comprehensive training data. By using crawler technology, elements of different types and states can be flexibly selected and collected. This means that the sample library can be continuously expanded according to actual needs, so that it has better adaptability and generalization ability. At the same time, crawler technology can also automatically collect data, reducing the workload of manual collection. By saving screenshots of elements as sample data, the quality of data can be guaranteed to a certain extent. Screenshots can provide accurate and repeatable image information, avoiding sample inconsistency problems caused by factors such as web page layout. This is very important for subsequent data processing and model training. In general, the technical effect of collecting a group of web page element image samples including different types and different states is to provide diversified, scalable and high-quality sample data, which provides a good foundation for subsequent technical research and application.
[0052] Furthermore, the step of realizing image recognition of web page elements by comparing the web page screenshot with the trained image recognition model specifically includes:
[0053] Based on existing browser extensions or self-developed tools, the screenshots are passed to the trained image recognition model for recognition and the recognition results are output;
[0054] The type and status of the element are determined by comparing the results output by the image recognition model.
[0055] In this embodiment, an existing browser extension or self-developed tool is used to take screenshots of web pages that need to be image recognized. These screenshots are passed into a trained image recognition model for recognition. The model can recognize various types of image elements. The model processes each input web page screenshot and outputs the corresponding recognition result. The recognition result includes information such as the type and status of each element in the web page. By comparing the results output by the image recognition model, the specific type and current status of each element in the web page can be determined. For example, it can be determined whether an element is a button, a text box, or whether it is in a selected, disabled, or other state. This embodiment can effectively identify various types of web page elements, and the tool can stably perform screenshot and recognition operations, which can achieve accurate image recognition of web page elements.
[0056] Furthermore, the step of verifying the located element specifically includes:
[0057] Check the attribute information of the element;
[0058] Compare the element's attribute information with the expected result.
[0059] If the attribute information of the element is consistent with the expected result, it means that the element is positioned accurately; if not, it means that the element is positioned inaccurately.
[0060] The attribute information of the element includes the text content and link address of the inspection element.
[0061] In this embodiment, the attributes of the element are checked, including but not limited to attributes such as text content and link address. By checking these attribute information, it can be determined whether the element meets expectations. Compare the attribute information of the element with the expected result: compare the attribute information of the element with the expected result to confirm whether the element is correctly located. The comparison method can be to compare the attributes one by one, or to use a specific algorithm for comprehensive judgment. Determine the accuracy of element positioning: According to the comparison result of the attribute information of the element with the expected result, the accuracy of element positioning can be obtained. If the attribute information of the element is consistent with the expected result, it means that the element is accurately positioned; if it is inconsistent, it means that the element is inaccurately positioned. This step has great application value in the fields of automated testing, web crawlers, etc. By verifying the elements, the accuracy of positioning can be improved, the occurrence of erroneous operations can be reduced, and the stability and reliability of the system can be increased. At the same time, it can also help developers to promptly discover and fix positioning errors and improve the quality and efficiency of software.
[0062] Example 2
[0063] A system for locating an element based on browser front-end image recognition, wherein the system for locating an element based on browser front-end image recognition is used to execute the method for locating an element based on browser front-end image recognition as described in Example 1.
[0064] Furthermore, the element positioning system based on browser front-end image recognition includes:
[0065] A data collection module, used for collecting a set of web page element image samples including different types and different states;
[0066] A model training module is used to train an image recognition model using a machine learning algorithm based on the collected web page element image samples;
[0067] An image recognition module is used to realize image recognition of web page elements by comparing web page screenshots with the trained image recognition model;
[0068] An element positioning module is used to locate elements based on the identified image information and the DOM structure of the web page;
[0069] Positioning result verification module, used to verify the positioned elements;
[0070] The positioning result correction module is used to improve the positioning accuracy by adjusting the parameters of the image recognition model or re-collecting and training samples when errors or inaccuracies occur during the element positioning process.
[0071] The above implementation modes are merely descriptions of the preferred implementation modes of the present invention, and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary engineering and technical personnel in the field shall fall within the protection scope determined by the claims of the present invention.
Claims
1. A method for locating elements based on browser front-end image recognition, characterized in that: The following steps are involved: Data collection: Collect a set of web page element image samples of different types and states; Model training: Based on the collected web page element image samples, use machine learning algorithms to train an image recognition model; Image recognition: By comparing web page screenshots with trained image recognition models, image recognition of web page elements is achieved; Element positioning: Element positioning is performed based on the recognized image information and the DOM structure of the web page.
2. The element positioning method based on browser front-end image recognition according to claim 1 is characterized in that: The element positioning method based on browser front-end image recognition also includes the following steps: Positioning result verification: verify the positioned elements; Correction of positioning results: If errors or inaccuracies occur during the element positioning process, the positioning accuracy can be improved by adjusting the parameters of the image recognition model or re-collecting and training samples.
3. The element positioning method based on browser front-end image recognition according to claim 1 is characterized in that: The machine learning algorithm is a convolutional neural network algorithm or a support vector machine algorithm.
4. The element positioning method based on browser front-end image recognition according to claim 1 is characterized in that: The step of collecting a group of web page element image samples of different types and different states specifically includes: Representative web page element image samples are collected through web crawler technology. Specifically, when crawling web pages, elements of different types and states are selected and their screenshots are saved as sample data.
5. The element positioning method based on browser front-end image recognition according to claim 4 is characterized in that: Different types of elements include buttons, input boxes, and text.
6. The element positioning method based on browser front-end image recognition according to claim 1 is characterized in that: The step of realizing image recognition of web page elements by comparing the web page screenshot with the trained image recognition model specifically includes: Based on existing browser extensions or self-developed tools, the screenshots are passed to the trained image recognition model for recognition and the recognition results are output; The type and status of the element are determined by comparing the results output by the image recognition model.
7. The element positioning method based on browser front-end image recognition according to claim 2 is characterized in that: The step of verifying the located element specifically includes: Check the attribute information of the element; Compare the element's attribute information with the expected result. If the attribute information of the element is consistent with the expected result, it means that the element is positioned accurately; if not, it means that the element is positioned inaccurately.
8. The element positioning method based on browser front-end image recognition according to claim 7 is characterized in that: The attribute information of the element includes the text content and link address of the inspection element.
9. An element positioning system based on browser front-end image recognition, characterized in that: The element positioning system based on browser front-end image recognition is used to execute the element positioning method based on browser front-end image recognition as described in any one of claims 1-8.
10. The element positioning system based on browser front-end image recognition according to claim 9, characterized in that: The element positioning system based on browser front-end image recognition includes: A data collection module, used for collecting a set of web page element image samples including different types and different states; A model training module is used to train an image recognition model using a machine learning algorithm based on the collected web page element image samples; An image recognition module is used to realize image recognition of web page elements by comparing web page screenshots with the trained image recognition model; An element positioning module is used to locate elements based on the identified image information and the DOM structure of the web page; Positioning result verification module, used to verify the positioned elements; The positioning result correction module is used to improve the positioning accuracy by adjusting the parameters of the image recognition model or re-collecting and training samples when errors or inaccuracies occur during the element positioning process.
Citation Information
Cited By
Interface element positioning method, device and system
CN120492358A
Interface element positioning method, device and system
CN120492358B
Web interface element identification method, system, equipment and medium
CN120894792A
Web interface element identification method, system, device and medium
CN120894792B
