CN117909246A - Automatic testing method and platform for front-end webpage interface - Google Patents

Automatic testing method and platform for front-end webpage interface Download PDF

Info

Publication number
CN117909246A
CN117909246A CN202410253069.9A CN202410253069A CN117909246A CN 117909246 A CN117909246 A CN 117909246A CN 202410253069 A CN202410253069 A CN 202410253069A CN 117909246 A CN117909246 A CN 117909246A
Authority
CN
China
Prior art keywords
test
target item
environment
user
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410253069.9A
Other languages
Chinese (zh)
Inventor
李康华
阮胜林
明德
詹楚伟
庄树坚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Baolun Electronics Co ltd
Original Assignee
Guangdong Baolun Electronics Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Baolun Electronics Co ltd filed Critical Guangdong Baolun Electronics Co ltd
Priority to CN202410253069.9A priority Critical patent/CN117909246A/en
Publication of CN117909246A publication Critical patent/CN117909246A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses an automatic testing method and platform for a front-end webpage interface, wherein the method comprises the following steps: responding to the selection of a target item after the user logs in, entering an end module in the selected target item, and further obtaining a test plan and test case content corresponding to the target item; the test plan is description data of the test case content execution, and the test case content is created and edited in the end module in advance by a user according to the target item; switching the test environment of the target item, and sequentially executing the test on the test case content according to the test plan, so as to generate a test result of the target item; and generating a test report corresponding to the target item according to the test result, and exporting a file of the test report. The invention solves the technical problems that the automatic webpage interface test cannot be carried out and the test efficiency is low in the prior art.

Description

Automatic testing method and platform for front-end webpage interface
Technical Field
The invention relates to the technical field of computers, in particular to an automatic testing method and platform for a front-end webpage interface.
Background
Existing automation techniques for front-end web interface testing include, but are not limited to, selenium-based test frames, appium mobile-end test frames, robot frame test frames, and the like.
The automation technology of the front-end webpage interface test can realize the automation test of Web application, mobile application and desktop application, and comprises the functions of positioning and operating page elements, data driving test and the like. However, there are problems associated with testing directly using automated test framework scripts, such as: when different personnel write scripts, the styles and the qualities are inconsistent, so that the communication efficiency among team members is low in aspects of handover, cooperation, code examination and the like; the dependency of the script on the page element is high, and the test script is easy to fail when the structure of the page element changes; UI automation test scripts of different platforms need to be adapted and customized for specific platforms, and partial identical contents cannot be shared, so that resource waste and repeated labor are caused, and the workload and cost of personnel are increased; the results of the automated test scripts are not visually friendly enough and are not integrated with third party office communication software, etc.
Disclosure of Invention
The invention provides an automatic testing method and platform for a front-end webpage interface, which are used for solving the technical problems that the automatic webpage interface test cannot be performed and the testing efficiency is low in the prior art.
In order to solve the above technical problems, an embodiment of the present invention provides an automated testing method for a front-end web interface, including:
responding to the selection of a target item after the user logs in, entering an end module in the selected target item, and further obtaining a test plan and test case content corresponding to the target item; the test plan is description data of the test case content execution, and the test case content is created and edited in the end module in advance by a user according to the target item;
Switching the test environment of the target item, and sequentially executing the test on the test case content according to the test plan, so as to generate a test result of the target item;
and generating a test report corresponding to the target item according to the test result, and exporting a file of the test report.
As a preferred solution, the step of responding to the selection of the target item after the user logs in, entering an end module in the selected target item, and further obtaining a test plan and test case content corresponding to the target item, specifically includes:
Responding to the creation or selection of the item after the user logs in, taking the created or selected item as a target item, and judging whether a corresponding running end module exists in the selected target item;
If the target item exists, entering an end module in the selected target item, and calling a test plan and test case content corresponding to the target item in the end module;
If the test case content does not exist, a new end module is built in the selected target item, and the new test case content and the generation of a test plan are carried out in the new end module.
Preferably, the test case content includes: failed retry control of use case execution, use case concurrency test control, monitoring use case setting, monitoring alarm execution and associated test scripts.
As a preferred solution, the switching the test environment of the target item, and sequentially executing the test on the test case content according to the test plan, so as to generate a test result of the target item, which specifically includes:
Sequentially switching the target items to a testing environment selected by a user; wherein, the test environment selected by the user is at least one, and the test environment comprises a development environment, a test environment, a pre-release environment and a production environment;
In each current test environment, executing the test on the content of the test case according to the test plan, and collecting test data in the test execution process;
And generating a test result corresponding to the content of each test case in the target item according to the test data.
Preferably, the method further comprises:
When the current testing environment is a development environment, a corresponding local debugging package is called according to the current target project, so that script files in the current development environment are checked according to a preset detection rule through the local debugging package; each script file configures a corresponding preset detection rule, wherein the preset detection rule comprises: code indentation and alignment, hump nomenclature, detection variables, underline nomenclature, code annotation information, use of spaces, length of code lines, structural style of code blocks;
and performing static code analysis on the result generated by checking the script file, thereby generating a code modification suggestion file of the current script file.
Correspondingly, the invention also provides an automatic testing platform of the front-end webpage interface, which is used for executing the automatic testing method of the front-end webpage interface, and comprises the following steps: the system comprises a user management module, a project management module, an end management module, a test case module, an environment switching module and a local debugging package;
the user management module is used for registering and logging in the user;
The project management module is used for responding to the selection of the target project after the user logs in, so as to manage the target project;
The terminal management module is used for managing target items in the terminal environments so as to obtain a test plan and test case contents corresponding to the target items;
The test case module is used for managing the content of the test case; and then, according to the test plan, sequentially executing the test on the test case content, thereby generating a test result of the target item;
The environment switching module is used for switching the test environment of the target item; the test environment comprises a development environment, a test environment, a pre-release environment and a production environment;
The local debugging package is used for debugging and testing the software in the development environment.
Preferably, the method further comprises: yun Yuansu library;
The Yun Yuansu library is used for storing element information on the front-end webpage; the element information comprises U I elements, element positioning modes and element operation methods.
Preferably, the Yun Yuansu library is further configured to:
Scanning the page elements of the current front-end webpage through a preset time period, and performing change judgment on the page elements of the current front-end webpage and element information in storage according to the attribute, the visibility, the state and the page structure of the current page elements;
When the element changes, positioning the changed page element, recording the execution strategy of successful current positioning, and further detecting the consistency of the attribute, the function and the position of the changed page element and the element information in the storage, so that the changed page element is more similar to the cloud element library after the consistency detection is passed.
As a preferred solution, the local debug packet is specifically configured to:
When the current testing environment is a development environment, a corresponding local debugging package is called according to the current target project, so that script files in the current development environment are checked according to a preset detection rule through the local debugging package; each script file configures a corresponding preset detection rule, wherein the preset detection rule comprises: code indentation and alignment, hump nomenclature, detection variables, underline nomenclature, code annotation information, use of spaces, length of code lines, structural style of code blocks;
and performing static code analysis on the result generated by checking the script file, thereby generating a code modification suggestion file of the current script file.
As a preferred solution, the user management module is specifically configured to:
and responding to the login of the user, and displaying item data corresponding to the identity of the user according to the login information of the user so that the user can select a corresponding item as a target item for automatic testing.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
according to the technical scheme, the target item is selected after the user logs in, the terminal module is entered, so that the test plan and the test case content of the target item are obtained, the test plans such as unified quality of all test scripts, automatic maintenance of page elements, multiplexing of cross-platform test scripts and the like are executed by switching corresponding test environments, and finally the test result, the test report and the file of the target item are generated, so that the automatic test of a webpage interface is effectively realized, the workload of the user for testing and maintaining the webpage is reduced, the test efficiency, the accuracy and the reliability are improved, the test cost of the front-end webpage is effectively reduced, and the cost of software development and maintenance is reduced.
Furthermore, the script static detection can be used for coding style specification, so that the code quality, the safety and the team cooperation efficiency are improved, and meanwhile, repeated resource multiplexing of the script can reduce repeated work, avoid resource waste and improve the working efficiency.
Drawings
Fig. 1: the embodiment of the invention provides a step flow chart of an automatic testing method for a front-end webpage interface;
Fig. 2: the embodiment of the invention provides a structural diagram of an automatic testing platform of a front-end webpage interface;
fig. 3: the front-end page logic relation diagram provided by the embodiment of the invention;
Fig. 4: the functional composition schematic diagram of the selenium platform provided by the embodiment of the invention;
fig. 5: the platform data flow chart provided by the embodiment of the invention
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
Referring to fig. 1, an automatic testing method for a front-end web interface according to an embodiment of the present invention includes steps S101 to S103:
step S101: responding to the selection of a target item after the user logs in, entering an end module in the selected target item, and further obtaining a test plan and test case content corresponding to the target item; the test plan is description data of the test case content execution, and the test case content is created and edited in the end module in advance by a user according to the target item.
As a preferred solution of this embodiment, the responding to the selection of the target item after the user logs in, enters the terminal module in the selected target item, and further obtains the test plan and the test case content corresponding to the target item, specifically:
Responding to the creation or selection of the item after the user logs in, taking the created or selected item as a target item, and judging whether a corresponding running end module exists in the selected target item; if the target item exists, entering an end module in the selected target item, and calling a test plan and test case content corresponding to the target item in the end module; if the test case content does not exist, a new end module is built in the selected target item, and the new test case content and the generation of a test plan are carried out in the new end module.
In the embodiment, by automatically identifying and entering the corresponding terminal module after the user logs in and selects or creates the project, the scheme can automatically call the test plan and the test case associated with the project, thereby reducing the need of manual configuration and setting and improving the efficiency of software testing. When a user needs to test an existing project, the system can quickly judge whether an operating end module exists in the project, and directly enter the existing module or create a new module according to the situation, so that the speed of starting and responding the project can be increased. In addition, by allowing a user to create a new end module in a target project, the solution supports modular test management so that different functional, different stage tests can be performed more orderly and independently.
In the embodiment, the test plan and the test case content are associated with specific projects and end modules, so that the test activity is guaranteed to closely follow the project requirements and the progress, and the pertinence and the effectiveness of the test are enhanced. Meanwhile, by multiplexing the existing test plan and the test case content, the time for creating new test resources can be saved, and accumulation and optimization of test assets can be promoted. Further, automatic retrieval of the test plans and use cases is helpful for reducing errors and omission caused by manual operation, guaranteeing the integrity and accuracy of test activities, and the test plans and use cases of each project are clearly recorded and archived, so that team members can conveniently track the test progress and result, and the transparency of project management is improved. When the project requirement changes, a user can quickly adjust or newly build an end module and a corresponding test plan and use cases, so that the test activity can adapt to the change in time.
As a preferable solution of this embodiment, the test case content includes: failed retry control of use case execution, use case concurrency test control, monitoring use case setting, monitoring alarm execution and associated test scripts.
In this embodiment, the creation and editing of the test case may include content control such as failed retry control of the execution of the test case, concurrent test control of the test case, setting of a monitoring case, execution of a monitoring alarm, and association with a test script, so as to perfect the test case and generate a test plan.
It can be understood that by means of measures such as automatic flow, modularized management, resource reuse and optimization, traceability and transparency improvement, the efficiency, quality and flexibility of software testing are remarkably improved, and the requirements of agile development and continuous integration are better met.
Step S102: and switching the test environment of the target item, and executing the test on the test case content in sequence according to the test plan, so as to generate a test result of the target item.
As a preferred solution of this embodiment, the switching the test environment of the target item, and sequentially executing the test on the test case content according to the test plan, so as to generate a test result of the target item, specifically:
sequentially switching the target items to a testing environment selected by a user; wherein, the test environment selected by the user is at least one, and the test environment comprises a development environment, a test environment, a pre-release environment and a production environment; in each current test environment, executing the test on the content of the test case according to the test plan, and collecting test data in the test execution process; and generating a test result corresponding to the content of each test case in the target item according to the test data.
In this embodiment, by allowing the user to select a plurality of different test environments (such as development, test, pre-release, and production environments), it is ensured that test activities can be performed under different conditions, which is helpful to find problems that may occur under different environments, increase the comprehensiveness of the test, and automatically execute test plans and use cases in the selected environments, reduce the need for manual setting, shorten the test period, and improve the overall test efficiency. Therefore, the test cases are automatically executed according to the test plan in each environment, and the test data are collected, so that the generated test result is more accurate and reliable, the test data are collected in the test execution process, the test progress and the quality index can be monitored in real time, and the test strategy can be conveniently adjusted in time and the test process can be optimized.
In the embodiment, through comprehensive testing in a plurality of environments, potential defects and problems can be found early, the risk of software deployment is reduced, and the testing results verified by different environments are beneficial to improving the quality of the final product, and the stability and reliability of the product under various conditions are ensured. Meanwhile, the automatic test flow reduces the requirement of human resources, thereby saving the test cost. In addition, the embodiment supports the flexible selection of the test environment by the user according to project requirements, adapts to changeable test requirements, and can promote continuous integration/continuous deployment (C I/CD), so that the automatic test can be supported to be integrated into a software development flow, the practice of continuous integration and continuous deployment can be realized, further accurate test results provide powerful support for project management and decision making, and a management layer can be helped to better understand project progress and risk conditions.
As a preferable mode of the present embodiment, further comprising:
when the current testing environment is a development environment, a corresponding local debugging package is called according to the current target project, so that script files in the current development environment are checked according to a preset detection rule through the local debugging package; each script file configures a corresponding preset detection rule, wherein the preset detection rule comprises: code indentation and alignment, hump nomenclature, detection variables, underline nomenclature, code annotation information, use of spaces, length of code lines, structural style of code blocks; and performing static code analysis on the result generated by checking the script file, thereby generating a code modification suggestion file of the current script file.
In this embodiment, the script file is checked by the preset detection rule, so as to ensure that the code follows the consistent coding standard and style, thereby improving the code normalization and readability of the whole project. Meanwhile, the static code analysis can discover potential coding problems such as grammar errors, unused variables and the like in an early stage of development, and reduce the later debugging and maintenance cost, thereby realizing automatic checking to replace or assist manual code examination, saving time and reducing quality problems caused by human negligence.
In this embodiment, the script file is checked by the preset detection rule, so as to ensure that the code follows the consistent coding standard and style, thereby improving the code normalization and readability of the whole project. Meanwhile, the static code analysis can discover potential coding problems such as grammar errors, unused variables and the like in an early stage of development, and reduce the later debugging and maintenance cost, thereby realizing automatic checking to replace or assist manual code examination, saving time and reducing quality problems caused by human negligence.
Further, when new developers join a project, the code modification suggestion file may serve as a reference to the coding specification, helping them quickly understand the style and specification of the project code, while enforcing specifications such as code indentation, naming rules, and notes to help maintain the clarity of the code, making the code easier to understand and maintain. In addition, the automatic code inspection avoids subjective judgment deviation possibly occurring in manual inspection, and improves the objectivity and accuracy of inspection. And the code quality inspection is integrated into the development flow, so that the continuous integration/continuous deployment (C I/CD) flow is more sound, the quick development is facilitated, the bug rate is reduced, the possibility of bug after software release is reduced by carrying out strict code inspection at the initial stage of development, and the stability of the final product is improved. For the primary developer, the code modification suggestion file given by the system can play an educational role and a standardization role, so that the primary developer can learn and improve coding skills, and meanwhile, automatic code checking reduces communication among team members for solving the inconsistent code styles, and improves team cooperation efficiency.
Step S103: and generating a test report corresponding to the target item according to the test result, and exporting a file of the test report.
In this embodiment, the conditions of the test results are integrated and summarized to generate a test report conforming to a standard format, including statistical data related to the execution conditions, the passing rate, the failure rate and the like of the test cases, and the test results are visually displayed in a manner of icons, tables and the like. At the same time, the HTTP request library is used by script to send message to Webhook address of nailing and flying book office software robot, the test report file is added to the message as attachment or detailed test result, and related personnel are informed
In this embodiment, the user performs creation or selection management of the item after registering and logging in; newly-built end modules or entry end modules in the project check detailed test plans and test case contents; the test cases are established and edited, so that the failed retry control of the execution of the cases, the concurrent test control of the cases, the setting of the monitoring cases, the execution of monitoring alarms, the control of the related test scripts and other contents are used for perfecting the test cases and generating a test plan; switching to a corresponding environment, and waiting for the completion of the test and the generation of a test result after executing the test plan; after the test is finished, the message can be pushed to office software such as nails for reminding, and meanwhile, a test report can be checked and a test report file can be exported on the platform.
Furthermore, the platform provides a cloud element library and a local debugging package, so that testers can write script codes quickly and debug and test software in a development environment, and script writing efficiency, code correctness and functional integrity are improved.
The implementation of the above embodiment has the following effects:
according to the technical scheme, the target item is selected after the user logs in, the terminal module is entered, so that the test plan and the test case content of the target item are obtained, the test plans such as unified quality of all test scripts, automatic maintenance of page elements, multiplexing of cross-platform test scripts and the like are executed by switching corresponding test environments, and finally the test result, the test report and the file of the target item are generated, so that the automatic test of a webpage interface is effectively realized, the workload of the user for testing and maintaining the webpage is reduced, the test efficiency, the accuracy and the reliability are improved, the test cost of the front-end webpage is effectively reduced, and the cost of software development and maintenance is reduced.
Furthermore, the script static detection can be used for coding style specification, so that the code quality, the safety and the team cooperation efficiency are improved, and meanwhile, repeated resource multiplexing of the script can reduce repeated work, avoid resource waste and improve the working efficiency.
Example two
Referring to fig. 2, an automated testing platform for a front-end web interface according to the present invention is provided, and the automated testing method for a front-end web interface according to the first embodiment of the present invention includes: the system comprises a user management module, a project management module, an end management module, a test case module, an environment switching module and a local debugging package.
The user management module is used for registering and logging in the user. And the user management module is used for controlling the registration and login of the user, distinguishing the project data through the identity of the user, and the user can only see the project data.
As a preferred solution of this embodiment, the user management module is specifically configured to:
and responding to the login of the user, and displaying item data corresponding to the identity of the user according to the login information of the user so that the user can select a corresponding item as a target item for automatic testing.
Further, preferably, the USER management may use the self-contained authentication system of django to process, configure Django the authentication system in settingpy, enable the django. Then creating a view to write and control the authority of the functional codes such as registration, login, logout and the like of the user, and directly using the self-contained user table of the django on the database. It should be noted that Django is a Web application framework of an open source written by Python for rapid development of a maintainable and extensible Web application.
And the project management module is used for responding to the selection of the target project after the user logs in, thereby managing the target project.
In this embodiment, the project management module is specifically configured to perform project management, including creation and configuration of project information, configuration of different terminal environments, different test environments, and so on, and overall planning and management of a project test plan are performed as a whole.
And the terminal management module is used for managing the target items in the terminal environments so as to obtain the test plans and the test case contents corresponding to the target items.
In this embodiment, the terminal management module belongs to different terminal environment management under project management, and software of different terminals may exist under one project, and is mainly used for isolating test data of different terminals, so as to ensure data independence of different terminals.
The test case module is used for managing the content of the test case; and then, according to the test plan, executing the test on the test case content in sequence, thereby generating a test result of the target item.
In this embodiment, the management of the test cases includes creating and editing the cases, failed retry control of the execution of the cases, concurrent test control of the cases, setting of the monitoring cases, execution of monitoring alarms, and content control of associated test scripts, which is one of the core functions of the platform.
The environment switching module is used for switching the test environment of the target item; the test environment comprises a development environment, a test environment, a pre-release environment and a production environment.
It should be noted that, in the software development process, testing may need to be performed under different environments, including a development environment, a testing environment, a pre-release environment, a production environment, and the like. The environment switching function can enable a user to conveniently switch different test environments so as to ensure stability and compatibility of software under each environment, and meanwhile, different test data may need to be used under different test environments, and the environment switching function can help the user to isolate and share the test data under different environments so as to ensure safety and reliability of the test data.
The local debugging package is used for debugging and testing the software in the development environment.
In this embodiment, the local debug package mainly performs software debugging and testing in a development environment, and can simulate various operations and data in a real environment to verify the correctness of codes and the integrity of functions. And meanwhile, practice display of coding specifications is carried out, so that a script writing personnel is guided to search for the specifications and styles. And in the later period, when the script is uploaded, static code analysis is carried out on the submitted test script so as to detect potential problems in the code and places with inconsistent styles, and help developers to discover and correct the style problems in the code in time.
As a preferred solution of this embodiment, the local debug packet is specifically configured to:
when the current testing environment is a development environment, a corresponding local debugging package is called according to the current target project, so that script files in the current development environment are checked according to a preset detection rule through the local debugging package; each script file configures a corresponding preset detection rule, wherein the preset detection rule comprises: code indentation and alignment, hump nomenclature, detection variables, underline nomenclature, code annotation information, use of spaces, length of code lines, structural style of code blocks; and performing static code analysis on the result generated by checking the script file, thereby generating a code modification suggestion file of the current script file.
In this embodiment, tools such as ESLint, pylint, shellCheck are used to integrate with the web platform, and inspection of script files such as JavaScript, python, shell is performed. Each script type configures corresponding detection rules, which may be created under the project root directory for ESLint. Eslintrc files, define code specifications and detection rules; rule configuration may be performed for Pylint to create pylintrc file; the required rules may be specified directly in the command line for SHELLCHECK; the setting of relevant rules includes, but is not limited to: code indentation and alignment, hump naming, detecting variables, underline naming, code annotation information, space usage, code line length, code block structural style and other rules, and detecting when uploading script to ensure the consistent style and quality of codes.
As a preferable mode of the present embodiment, further comprising: yun Yuansu library; the Yun Yuansu library is used for storing element information on the front-end webpage; the element information includes UI elements, element positioning modes and element operation methods.
Preferably, the Yun Yuansu library is further configured to:
Scanning the page elements of the current front-end webpage through a preset time period, and performing change judgment on the page elements of the current front-end webpage and element information in storage according to the attribute, the visibility, the state and the page structure of the current page elements; when the element changes, positioning the changed page element, recording the execution strategy of successful current positioning, and further detecting the consistency of the attribute, the function and the position of the changed page element and the element information in the storage, so that the changed page element is more similar to the cloud element library after the consistency detection is passed.
In this embodiment, the cloud element library is a collection of various element information on a storage page, and generally includes various U I elements of a web page, a mobile application or other application programs, such as buttons, input boxes, drop-down menus, tables, and the like, which can help a tester to centrally manage information of various elements on the page, including positioning modes (such as XPath, CSS selector, ID, and the like) of the elements and corresponding operation methods, so that writing of test scripts is improved; meanwhile, the page element library enables different test scripts to share the same group of page element information, so that the repeated writing of the same element positioning code is avoided, and the reusability of the test scripts is improved.
Further, by periodically scanning the page elements, the current page elements are compared with the previously stored element data to determine if the elements have changed. When the elements are changed, the changed page elements are automatically positioned, and then the elements in the cloud element library are updated.
The implementation of the above embodiment has the following effects:
according to the technical scheme, the target item is selected after the user logs in, the terminal module is entered, so that the test plan and the test case content of the target item are obtained, the test plans such as unified quality of all test scripts, automatic maintenance of page elements, multiplexing of cross-platform test scripts and the like are executed by switching corresponding test environments, and finally the test result, the test report and the file of the target item are generated, so that the automatic test of a webpage interface is effectively realized, the workload of the user for testing and maintaining the webpage is reduced, the test efficiency, the accuracy and the reliability are improved, the test cost of the front-end webpage is effectively reduced, and the cost of software development and maintenance is reduced.
Furthermore, the script static detection can be used for coding style specification, so that the code quality, the safety and the team cooperation efficiency are improved, and meanwhile, repeated resource multiplexing of the script can reduce repeated work, avoid resource waste and improve the working efficiency.
Example III
The embodiment provides an automated testing platform for a front-end web interface employing a python+django+ vue technical framework, and referring specifically to fig. 3, for performing the method as in the first embodiment and implementing the platform as in the second embodiment. In this embodiment, development is performed based on a selenium test framework according to a mtv design mode, referring to fig. 4 specifically, including user login, project management, each end module, and test cases, test reports, environment switching, local debug packages and cloud element libraries under each end module. Wherein Python is an object-oriented interpreted computer programming language; django is a Web application framework of open source code written by Python for rapid development of maintainable and extensible Web applications; vue is a JavaScript framework for building a user interface, and is mainly used for developing Web application programs; selenium is a tool for Web application testing that can be used to simulate user operations.
Please refer to fig. 5, which is a flowchart of the platform data flow chart of the present embodiment. The initial construction of the web platform of this embodiment is a quick build of the platform by using Django. Illustratively, the pip library management tool of python is used to install Django the framework, then the instructions of django are used to create projects and applications, and then the manage instructions are used for data synchronization, at which time the django server is started to access Django applications through http:// 127.0.0.1:8000/at the browser.
After the platform is built, the front-end page is created: the platform uses the Vue framework to design the web page, and the specific steps are as follows: the computer environment is provided with node. Js, vueCLI and other environments; then use Vue to create the project, at which time the project is run before you can view your Vue application through http:// localhost 8080/at the browser. Further, the association of the front end vue and the background django is achieved: at this time, the platform uses Vue.js as a front end frame, django as a back end frame to develop front-back end separation, in the Vue.js, a front end page path is defined through routing, and a routing path and a corresponding component of the front end page are defined in a router/index.js file of the Vue.js, so as to be used for navigation and display of the front end page; in Django, defining a back end API interface through URL routing, defining a URL path of the back end API and a corresponding view function in a url.py file of Django, for processing a request sent by the front end and returning data, such as; the get_elements method is called (i.e., the get element method) and the data returned by the get_elements method is contained in a HttpResponse object (i.e., the HTTP response object, which is an object used in the Django framework to return data and state information to the client) and returned. In association, axios or other HTTP client library is used in the Vue component to send HTTP requests to Django backend APIs, obtain data and expose and interact at the front end, such as: form loading methods using tables, using dynamic loading data, and the like. After the front-end item is finished, the Vue item is packaged into static files, and then the files are deployed into a Django static file catalog, so that the access of the front-end page and the display of data can be performed through the django.
It should be noted that, the USER management function of the USER management module may use the self-carried authentication system of django to process, configure Django the authentication system in settingpy, enable the django. Then creating a view to write and control the authority of the functional codes such as registration, login, logout and the like of the user, and directly using the self-contained user table of the django on the database.
In this embodiment, script static detection, checking of script files such as JavaScript, python, shell is performed by integrating with the web platform using tools such as ESLint, pylint, shellCheck. Each script type configures corresponding detection rules, which may be created under the project root directory for ESLint. Eslintrc files, define code specifications and detection rules; rule configuration may be performed for Pylint to create pylintrc file; the required rules may be specified directly in the command line for SHELLCHECK; the setting of relevant rules includes, but is not limited to: code indentation and alignment, hump naming, detecting variables, underline naming, code annotation information, space usage, code line length, code block structural style and other rules, and detecting when uploading script to ensure the consistent style and quality of codes.
In this embodiment, elements of the Yun Yuansu library are automatically maintained, and by periodically scanning page elements, the current page elements are compared with the previously stored element data to determine if the elements have changed. Specifically, monitoring the attribute of the page element, such as ID, class, XPath, and comparing the change of the attribute of the page element to judge whether the page element is changed or not; detecting the visibility of the page element, which may mean that the page element is changed if the page element is no longer visible on the page; capturing a screenshot of a page for comparison, periodically capturing the screenshot of the page, and comparing with the previous version to detect the change of the page element; monitoring page element states, such as clickable states of buttons, content of input boxes, etc., which if changed may mean that there is a change in the page element; the page structure changes are monitored, including changes to the DOM tree structure, newly added or removed elements, and the like.
Further, when the element changes, the element positioning and updating are automatically performed, and the specific steps are as follows: collecting positioning failure information in the test execution process, including errors such as element non-finding, overtime and the like, recording a failed positioning strategy and corresponding page information, such as father nodes, text content, other characteristics and the like of the elements, and extracting characteristics of the page elements aiming at the collected failed positioning information, including but not limited to XPath paths, CSS selectors, custom attributes, text content and the like of the elements; a rule list is defined, and different positioning rules are tried in turn according to a certain order. For example, an attempt may be made to locate using the id of the element first, and if a failure occurs to re-attempt to locate using class or other attributes, after each rule attempt, an exception that the location failed needs to be captured. If the positioning fails, the program continues to try the next rule until a suitable positioning strategy is found or all rules are tried. Different rule lists may be defined for different types of elements. For example, for a drop down box, one may try first to use the location rule of the select tag and try another way if it fails. After successful positioning, the successful positioning strategy can be saved, and the saved successful strategy can be preferentially used when the elements of the same type are tried to be positioned again next time, so that the efficiency is improved. It should be noted that, when the new element is located and acquired, it is verified whether the attribute of the new element is consistent with the attribute of the old element. For example, it may be compared whether the attributes of the element, such as id, class, text content, location, etc., are consistent with the old element; performing some functional tests to verify whether the functions of the new element and the old element are consistent; the method comprises the steps of performing screenshot on a page operated by a new element, and comparing the screenshot with the screenshot of an old element; the position, appearance and implementation function on the page are unchanged, and can be regarded as consistent, and cloud elements are updated.
In this embodiment, the resources of the cloud element library may be multiplexed, that is, scripts written for different platforms may be integrated with the multiplexed resources, and the cloud element library may be stored and displayed. Specifically, the existing U I automatic test script is analyzed, common operations of different platforms, such as page skip, element positioning, data input, button clicking and the like, are identified, and are abstracted into independent operation functions or methods to form a common operation library or module, and the operation library can be referenced by the test scripts of different platforms; the method comprises the steps of introducing a Page Object mode, abstracting each Page into a Page Object class, wherein the Page Object class comprises a positioning and operating method of Page elements, and referring to the corresponding Page Object class in test scripts of different platforms, so that multiplexing of the test scripts is realized; the configuration parameters, such as URL, user name, password and the like, which are required to be extracted according to different platforms in the test script are stored in separate configuration files, the configuration information of each platform is stored independently, and the test script acquires the configuration parameters of different platforms by reading the configuration files; the test data is abstracted and parameterized, the test data can be managed in a configuration file or data driving mode, and the test script obtains the corresponding test data by reading the configuration file or the data driving file, so that the same test data is multiplexed in the test scripts of different platforms.
In this embodiment, the test report may be visualized and integrated with office software, and by designing a code using un ittest framework, the conditions of the test results are integrated and summarized to generate a test report conforming to a standard format, including statistics related to the execution condition, the passing rate, the failure rate, and the like of the test case, and at the same time, the test results are visually displayed in a manner of icons, tables, and the like. Meanwhile, the HTTP request library is used by the script to send a message to Webhook addresses of the nailing and book flying office software robots, and a test report file is added to the message as an attachment or a detailed test result to inform related personnel.
In the embodiment, the platform-level automatic test scheme realizes unified management and control, improves test efficiency, accuracy and reliability, reduces cost of software development and maintenance, and can normalize coding styles by script static detection, thereby being beneficial to improving code quality, safety and team cooperation efficiency. Further, the cloud element library and the automatic maintenance and updating of elements can reduce the dependence of the script on page elements, improve the stability of the script, reduce the repeated work of repeated resource reuse of the script, avoid the waste of resources, improve the working efficiency, display the visualized test report, and simultaneously solve the presentation requirements of the report under different office software.
The foregoing embodiments have been provided for the purpose of illustrating the general principles of the present invention, and are not to be construed as limiting the scope of the invention. It should be noted that any modifications, equivalent substitutions, improvements, etc. made by those skilled in the art without departing from the spirit and principles of the present invention are intended to be included in the scope of the present invention.

Claims (10)

1. An automated testing method for a front-end web interface, comprising the steps of:
responding to the selection of a target item after the user logs in, entering an end module in the selected target item, and further obtaining a test plan and test case content corresponding to the target item; the test plan is description data of the test case content execution, and the test case content is created and edited in the end module in advance by a user according to the target item;
Switching the test environment of the target item, and sequentially executing the test on the test case content according to the test plan, so as to generate a test result of the target item;
and generating a test report corresponding to the target item according to the test result, and exporting a file of the test report.
2. The method for automatically testing a front-end web interface according to claim 1, wherein the step of entering an end module in the selected target item in response to the selection of the target item after the user logs in, further obtaining a test plan and test case content corresponding to the target item comprises the steps of:
Responding to the creation or selection of the item after the user logs in, taking the created or selected item as a target item, and judging whether a corresponding running end module exists in the selected target item;
If the target item exists, entering an end module in the selected target item, and calling a test plan and test case content corresponding to the target item in the end module;
If the test case content does not exist, a new end module is built in the selected target item, and the new test case content and the generation of a test plan are carried out in the new end module.
3. The automated testing method of a front-end web interface of claim 2, wherein the test case contents comprise: failed retry control of use case execution, use case concurrency test control, monitoring use case setting, monitoring alarm execution and associated test scripts.
4. The automatic testing method of the front-end web interface according to claim 1, wherein the switching the testing environment of the target item and sequentially testing the content of the test case according to the testing plan, so as to generate the testing result of the target item comprises the following steps:
Sequentially switching the target items to a testing environment selected by a user; wherein, the test environment selected by the user is at least one, and the test environment comprises a development environment, a test environment, a pre-release environment and a production environment;
In each current test environment, executing the test on the content of the test case according to the test plan, and collecting test data in the test execution process;
And generating a test result corresponding to the content of each test case in the target item according to the test data.
5. The automated testing method of a front-end web interface of claim 4, further comprising:
When the current testing environment is a development environment, a corresponding local debugging package is called according to the current target project, so that script files in the current development environment are checked according to a preset detection rule through the local debugging package; each script file configures a corresponding preset detection rule, wherein the preset detection rule comprises: code indentation and alignment, hump nomenclature, detection variables, underline nomenclature, code annotation information, use of spaces, length of code lines, structural style of code blocks;
and performing static code analysis on the result generated by checking the script file, thereby generating a code modification suggestion file of the current script file.
6. An automated testing platform for a front-end web interface, configured to perform the automated testing method for a front-end web interface according to any of claims 1-5, comprising: the system comprises a user management module, a project management module, an end management module, a test case module, an environment switching module and a local debugging package;
the user management module is used for registering and logging in the user;
The project management module is used for responding to the selection of the target project after the user logs in, so as to manage the target project;
The terminal management module is used for managing target items in the terminal environments so as to obtain a test plan and test case contents corresponding to the target items;
The test case module is used for managing the content of the test case; and then, according to the test plan, sequentially executing the test on the test case content, thereby generating a test result of the target item;
The environment switching module is used for switching the test environment of the target item; the test environment comprises a development environment, a test environment, a pre-release environment and a production environment;
The local debugging package is used for debugging and testing the software in the development environment.
7. The automated test platform of claim 6, further comprising: yun Yuansu library;
the Yun Yuansu library is used for storing element information on the front-end webpage; the element information includes UI elements, element positioning modes and element operation methods.
8. The automated testing platform of claim 6, wherein the Yun Yuansu library is further configured to:
Scanning the page elements of the current front-end webpage through a preset time period, and performing change judgment on the page elements of the current front-end webpage and element information in storage according to the attribute, the visibility, the state and the page structure of the current page elements;
When the element changes, positioning the changed page element, recording the execution strategy of successful current positioning, and further detecting the consistency of the attribute, the function and the position of the changed page element and the element information in the storage, so that the changed page element is more similar to the cloud element library after the consistency detection is passed.
9. The automated test platform of claim 6, wherein the local debug package is specifically configured to:
When the current testing environment is a development environment, a corresponding local debugging package is called according to the current target project, so that script files in the current development environment are checked according to a preset detection rule through the local debugging package; each script file configures a corresponding preset detection rule, wherein the preset detection rule comprises: code indentation and alignment, hump nomenclature, detection variables, underline nomenclature, code annotation information, use of spaces, length of code lines, structural style of code blocks;
and performing static code analysis on the result generated by checking the script file, thereby generating a code modification suggestion file of the current script file.
10. The automated testing platform of claim 6, wherein the user management module is specifically configured to:
and responding to the login of the user, and displaying item data corresponding to the identity of the user according to the login information of the user so that the user can select a corresponding item as a target item for automatic testing.
CN202410253069.9A 2024-03-06 2024-03-06 Automatic testing method and platform for front-end webpage interface Pending CN117909246A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410253069.9A CN117909246A (en) 2024-03-06 2024-03-06 Automatic testing method and platform for front-end webpage interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410253069.9A CN117909246A (en) 2024-03-06 2024-03-06 Automatic testing method and platform for front-end webpage interface

Publications (1)

Publication Number Publication Date
CN117909246A true CN117909246A (en) 2024-04-19

Family

ID=90685354

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410253069.9A Pending CN117909246A (en) 2024-03-06 2024-03-06 Automatic testing method and platform for front-end webpage interface

Country Status (1)

Country Link
CN (1) CN117909246A (en)

Similar Documents

Publication Publication Date Title
CN105094783B (en) method and device for testing stability of android application
US8881105B2 (en) Test case manager
US7913230B2 (en) Computer-implemented methods and systems for generating software testing documentation and test results management system using same
AU2017258963A1 (en) Simultaneous multi-platform testing
CN108038054B (en) Automatic testing method and device and computer readable storage medium
CN111858371A (en) Software testing method, system, storage medium and computer equipment
CN112131116B (en) Automatic regression testing method for embedded software
CN115658529A (en) Automatic testing method for user page and related equipment
Liu et al. Guided bug crush: Assist manual gui testing of android apps via hint moves
CN102479152A (en) Method and device for obtaining tool automatic test results on basis of Android platform
Helfen et al. Testing SAP solutions
CN113742215B (en) Method and system for automatically configuring and calling test tool to perform test analysis
WO2007118271A1 (en) A method and system and product for conditioning software
CN110286882B (en) Foreground system design and verification method based on model detection
CN116719736A (en) Test case generation method and device for testing software interface
CN117909246A (en) Automatic testing method and platform for front-end webpage interface
TW202303388A (en) Device and method for identifying errors in a software application
CN112162921B (en) Industrial automation test and control system
Vahlbrock et al. VSCode Migrate: Semi-Automatic Migrations for Low Coverage Projects
CN112579443B (en) Automatic testing method and platform of intelligent testing robot
CN117762802A (en) Automatic test method, device, equipment and storage medium
Cao et al. Software Testing Strategy for Mobile Phone
CN112765040A (en) Page testing method, system, computer equipment and storage medium
Pereira Development of a Self-diagnosis Tests System for Integration in a Cyber-physical System
Kshetri Automated web testing using Robot Framework and Python

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination