CN109902016B - Web test method and test platform - Google Patents

Web test method and test platform Download PDF

Info

Publication number
CN109902016B
CN109902016B CN201910161259.7A CN201910161259A CN109902016B CN 109902016 B CN109902016 B CN 109902016B CN 201910161259 A CN201910161259 A CN 201910161259A CN 109902016 B CN109902016 B CN 109902016B
Authority
CN
China
Prior art keywords
configuration file
test
case
page
node
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.)
Active
Application number
CN201910161259.7A
Other languages
Chinese (zh)
Other versions
CN109902016A (en
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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201910161259.7A priority Critical patent/CN109902016B/en
Publication of CN109902016A publication Critical patent/CN109902016A/en
Application granted granted Critical
Publication of CN109902016B publication Critical patent/CN109902016B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a Web test method and a test platform, wherein a manual test case is firstly obtained, and an automatic case, a page configuration file and an execution case configuration file are generated according to the manual test case; determining version information of the browser to be tested according to the execution case file, and acquiring and updating a Driver file matched with the version information of the browser to be tested; and finally, executing the test according to the automatic use case, the page configuration file and the execution use case configuration file. The invention has fast testing speed, can map manual testing and automatic testing mutually, can combine the automatic testing and the manual testing together, is more beneficial to systematized management of test cases, also reduces the testing cost, and can match the testing platform with the browser before testing without manual matching and also can improve the testing efficiency.

Description

Web test method and test platform
Technical Field
The invention relates to the field of network communication, in particular to a Web test method and a Web test platform.
Background
Since Web applications are directly related to users and usually need to endure a lot of operations for a long time, the functions and performances of Web items must be reliably verified, and thus, the Web items are subjected to a comprehensive test. With the progress and development of internet technology, more and more automatic testing frameworks are applied to various fields of the internet.
The testing tool used at present has the following defects: the manual use case and the automatic use case in the testing tool are stored in two places, the configuration file, the testing parameters and the cross-platform compatibility test all need to be manually loaded and the corresponding testing environment is selected, and for a new person or a person who is not familiar with codes, the cost for learning and compiling the testing use case and positioning the reason of the error report of the page is high.
Another problem is that since the local browser is automatically upgraded, the WebDriver of the test framework often does not conform to the browser, which causes various problems. And when the system needs to be tested in different environments, the data files in the system are not matched with the test browser, and the data files in the system need to be frequently replaced, so that the test efficiency is greatly reduced, and the test workload is increased.
Disclosure of Invention
In view of the above, embodiments of the present invention are proposed to provide a Web testing method and a Web testing platform that overcome or at least partially solve the above problems.
In order to solve the above problem, an embodiment of the present invention discloses a method for testing a Web, including the following steps:
acquiring a manual test case, and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
determining version information of the browser to be tested according to the execution case file, and acquiring and updating a Driver file matched with the version information of the browser to be tested;
and executing the test according to the automatic use case, the page configuration file and the execution use case configuration file.
Optionally, the manual test case includes basic test parameters, a test URL, a case ID, case keywords, a case name, test steps, and test data;
generating a case execution configuration file according to the basic test parameters, the case names and the case keywords;
generating a page configuration file according to the test URL and the case ID;
and generating an automatic case according to the test steps and the test result.
Optionally, the obtaining and updating the Driver file matched with the version information of the browser to be tested includes:
reading the name of a target browser, wherein the target browser is a browser which needs to be tested and executes a case configuration file;
acquiring version information of the target browser according to the name of the target browser;
searching Driver version information matched with the target browser version information from a preset mapping information table;
and acquiring and loading a corresponding Driver file from a preset Driver application pool according to the Driver version information.
Optionally, the obtaining and loading a Driver file matched with the version information of the browser to be tested further includes:
determining a tested environment according to the execution test configuration file;
acquiring a corresponding Host file according to the tested environment;
and replacing the Host file in the system according to the corresponding Host file.
Optionally, executing the test according to the automation use case, the page configuration file and the execution use case configuration file comprises;
executing a basic function test according to the steps of executing the case file and the automatic case;
performing CSS label test according to the steps of the page configuration file and the automation case;
and executing the picture similarity test according to the steps of the page configuration file and the automatic case.
Optionally, the image similarity test is executed according to the steps of the page configuration file and the automated case, and the method further includes:
acquiring an href link of the current element configuration file, sending an HTTP request to the href link to open the link, and judging whether a return value of the HTTP request is correct or not;
if the returned value of the transmitted HTTP request is wrong, sending a case error reporting instruction;
if the returned value of the sent HTTP request is correct, pulling the current page display picture P1 and the href configuration link picture P2, and judging whether the check values of P1 and P2 are the same;
if the check values are the same, determining that the pictures are the same;
if the check values are different, comparing the image entropy values of the pictures by a picture similarity calculation method;
if the number of the pictures is smaller than the entropy value, determining that the pictures are the same;
if the picture is larger than the entropy value, determining that the pictures are different, and sending a case error reporting indication.
Optionally, the method further comprises:
regenerating a new page configuration file according to the page configuration file, and judging whether the new page configuration file is the same as the original page configuration file or not;
if the page configuration files are the same, replacing the original page configuration file with the new page configuration file;
and if not, replacing the original page configuration file with the new page configuration file.
Optionally, acquiring a new page configuration file through the CSS pseudo code and the tree table, where the page configuration file includes a root element configuration file and a measured element configuration file, and acquiring the new page configuration file includes:
extracting a DOM tree structure of a root node of the tested page according to the page configuration file;
forming a root element configuration file according to the DOM tree structure of the root node of the page to be tested;
acquiring the information of the configuration file of the element to be tested according to the root element configuration file;
and generating a tested element configuration file according to the tested element configuration file information.
Optionally, forming a root element configuration file according to the DOM tree structure of the root node of the page to be tested, including:
acquiring a root node of a page to be tested;
acquiring a unique identification node under a root node according to the root node;
and acquiring a root element configuration file according to the unique identification node under the root node.
Optionally, obtaining a root node of the detected page further includes:
acquiring a unique identifier under a root node according to the root node of the detected page, and judging whether the root node of the detected page has a unique ID identifier or not;
if the root node of the tested page has the unique ID, recording the unique ID, and acquiring the root node by using the ID;
if the root node of the tested page does not have the unique ID node, judging whether the root node of the tested page has a CSS node or not;
and if the root node of the tested page has the CSS node, recording the CSS identification, and acquiring the root node by using the CSS identification.
If the root node of the tested page has no CSS node, an element array is positioned through the CSS, and whether the element is uniquely positioned through the inclusion of a pseudo class is judged;
if the positioning can be carried out, recording positioning information, and acquiring a root node by using the positioning information;
if the root node can not be positioned, positioning is carried out through the position label, and the position label is recorded, so that the root node is obtained through the position label.
Optionally, the acquiring, according to the root node, a unique identification node under the root node further includes:
and extracting nodes with ID identification under root nodes, identifying the information of the nodes through the ID, recording father node information of the nodes, and taking the father node information as the unique identification under the root nodes, thereby obtaining the unique identification nodes under the root nodes.
Optionally, generating the measured element configuration file according to the measured element configuration file information includes:
judging whether the current node has a unique ID (identity);
if the current node has the unique ID, recording the ID as the unique ID into the original tested element configuration file, and generating a new tested element configuration file so as to obtain a new page configuration file;
if the current node has no ID identification, judging whether the current node has a unique CSS identification;
if the current node has the unique CSS identification, the CSS identification is used as the unique identification to be recorded in the original element configuration file to be tested, and a new element configuration file to be tested is generated, so that a new page configuration file is obtained;
if the current node does not have the unique CSS identifier, acquiring a content element, a left brother node, a right brother node or a grandfather node with the unique identifier of the current node, recording the content element, the left brother node, the right brother node or the grandfather node with the unique identifier into an original element configuration file to be tested, and generating a new element configuration file to be tested so as to acquire a new page configuration file.
Optionally, the method further includes obtaining a test result, and generating a test report according to the test result.
The invention also provides a Web test platform, which comprises a case generation module, a file loading module and a test module;
the case generation module is used for acquiring a manual test case and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
the file loading module is used for determining version information of the browser to be tested according to the execution case file, and acquiring and updating a Driver file matched with the version information of the browser to be tested;
the test module is used for executing tests according to the automation use cases, the page configuration files and the execution use case configuration files.
The invention also proposes a device comprising:
one or more processors; and
one or more machine readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform a method as described above.
The present invention also proposes one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the method as described above.
In the embodiment of the invention, a manual test case is firstly obtained, an automation case, a page configuration file and an execution case file are generated according to the manual test case, then a Driver file is matched and updated, and then the Web is tested according to the automation case, the page configuration file and the execution configuration file. The testing method provided by the invention has the advantages that the testing process is quick, the mapping relation from manual testing to automatic testing can be solved, the automatic testing and the manual testing can be combined, the systematic management of the test cases is more facilitated, the testing cost is reduced, the testing platform is matched with the browser before testing, the manual matching is not needed, and the testing efficiency can be improved.
Drawings
FIG. 1 is a flow diagram illustrating steps of one embodiment of a method for testing a Web;
FIG. 2 is a schematic flowchart of steps of an embodiment of a method for testing a Web
FIG. 3 is a diagram illustrating an update Driver file according to an embodiment of the present invention;
FIG. 4 is a diagram of updating a Host file according to one embodiment of the present invention;
FIG. 5 is a flowchart illustrating a process of obtaining a new page profile according to an embodiment of the invention;
FIG. 6 is a flow diagram illustrating a process for obtaining a root element profile according to an embodiment of the invention;
FIG. 7 is a flowchart illustrating a process of obtaining a root node of a page under test according to an embodiment of the present invention;
FIG. 8 is a schematic flow chart illustrating a process of acquiring a unique identifier node under a root node according to an embodiment of the present invention;
FIG. 9 is a flowchart illustrating a process for obtaining information of a configuration file of an element under test according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of a process flow of image testing according to one embodiment of the present invention;
FIG. 11 is a schematic diagram of a rerun mechanism in one embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 1, a flowchart of steps of one embodiment of a Web testing method according to the present invention is shown, where the method is used to test an internet Web, and in this embodiment, a testing application may be directly used during testing, or an independent Web Service may be loaded on a platform such as a testing platform or a Web server to test the internet Web. In this embodiment, the method may specifically include the following steps:
step 101, acquiring a manual test case, and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
because the manual use case and the automatic use case of the traditional self-adaptive Web automatic test need to be stored separately, when the cross-platform compatibility test needs to be manually loaded and the corresponding test environment is selected each time, for a new person or a person unfamiliar with codes, the cost for learning and compiling the test case and positioning the reason of the error report of the page is higher.
In this embodiment, a generation case may be formed by combining the required keywords, test parameters, and the like, and corresponding configuration files and test steps may be generated according to the required keywords, test parameters, and the like, so as to implement generation of an automated case, which may increase practicality and reliability of a test, and may also reduce test cost.
102, determining version information of a tested browser according to the execution case file, acquiring a Driver file matched with the tested browser, and updating a Driver file of a test platform according to the Driver file;
because the local browser of the user has an automatic updating function, the Webdriver used in the Web test is often not matched with the browser version, so that the problems of wrong test case report or incapability of testing and the like can be caused; and in the tested Web access page, if the IP address of the Web access page is not matched with the IP address corresponding to the commonly-used Web access page established by the locally-stored system file Host, the test environment is different, and the test cannot be automatically operated.
The Web testing method provided by the invention can update the Webdriver used in the testing and the locally stored system file Host before each testing, so that the matching of the used Webdriver and the version of the tested browser is ensured, the IP address of the Web access page is matched with the IP address corresponding to the commonly used Web access page established by the system file Host, the testing error is avoided, and the testing efficiency is improved.
103, executing a test according to the automatic use case, the page configuration file and the execution use case configuration file;
the three files of the automatic case, the page configuration file and the execution case configuration file are acquired for testing, so that the test result is more accurate and visual, and the three files of the automatic case, the page configuration file and the execution case configuration file are generated through manual cases which can be input by hands, so that the test parameters, the test steps and the like can be increased during input, the test range is enlarged, and the test accuracy is further improved.
In the embodiment of the invention, the required keywords, test parameters, test steps and other manual cases can be manually input or the existing manual cases can be input and called, then the cases are generated according to the required keywords, test parameters and the like, corresponding configuration files and test steps are generated according to the generated cases, then the local browser IP of the tested system is read according to the configuration files and the test steps, the local browser version IP is updated to a preset Driver file, the version of the Web to be tested is the same as that of the tested equipment, and then the test is executed according to the configuration files and the test steps. The whole testing process is quick, the mapping relation from manual testing to automatic testing can be solved, the automatic testing and the manual testing can be combined, systematic management of test cases is facilitated, testing cost is reduced, the testing platform is matched with the browser before testing, manual matching is not needed, and testing efficiency can be improved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 2, a flowchart of steps of an embodiment of a Web testing method according to the present invention is shown, in this embodiment, a testing tool (e.g., a server or a testing platform with a Web Service, a server or a testing platform with various testing processes, a testing platform or a server with a selenium automation testing tool, etc.) may be used for testing, and the method may specifically include the following steps:
step 201, acquiring a manual test case, and generating an automation case, a page configuration file and an execution case configuration file according to the manual test case;
the manual test case can be input by hands, and can be written by hands, and the manual test case written by hands can comprise basic test parameters, test URLs, case IDs, case keywords, case names, test steps, test data and the like;
generating a case execution configuration file according to the basic test parameters, the case names and the case keywords, wherein the generated case execution file is a text.
Generating a page configuration file according to the test URL and the case ID, wherein the generated page configuration file is a Properties file;
and generating an automatic case according to the test step and the test result, and packaging the jar file generated by the automatic case. The test result may be an expected test result written manually or a test result of a last test. The purpose of generating the test result into the automatic case is to compare the finally obtained test result with the input test result when the test result is finally obtained, so that technicians can conveniently analyze the test result after the test.
The manually written manual test case can store the manual case and the automatic case together, so that the management is more convenient, and the configuration file can be quickly generated; when the cross-platform compatibility test is carried out, the corresponding test environment can be directly loaded and selected, and the test efficiency is improved. Even a new person or a person who is not familiar with the code can reduce the error probability and the test cost. The manual test case can be manually input or manually guided into the manual test case.
Step 202, determining version information of the browser to be tested according to the execution case file, and acquiring and updating a Driver file matched with the version information of the browser to be tested.
Referring to fig. 3, step 202 may further include the following sub-steps:
step S2021, reading the name of a target browser to be tested, wherein the target browser is a browser which needs to be tested and executes a case configuration file;
substep S2022, obtaining the version information of the target browser according to the name of the target browser;
substep S2023, searching Driver version information matched with the target browser version information from a preset mapping information table;
and a substep S2024 of acquiring a corresponding Driver file from a preset Driver application pool according to the Driver version information and loading the corresponding Driver file.
The version information of the browser to be tested is determined according to the execution case file, so that the version information of the browser to be tested is matched with the version information of the browser to be tested, and the browser to be tested has an automatic upgrading function, so that the version information of the browser to be tested is often not matched with a test device or a test platform, various problems are caused, manual matching is required, and the test efficiency is reduced. And the version information of the browser to be tested is matched before testing, so that the testing error can be avoided.
Referring to fig. 4, step 202 may further include the following sub-steps:
substep S2025, determining a tested environment according to the execution case file;
substep S2026, obtaining a corresponding Host file according to the tested environment;
and a substep S2027 of replacing the Host file in the system according to the corresponding Host file.
And determining a test environment while determining the version information of the browser to be tested according to the execution case file, wherein the test environment can comprise a main environment, an STG (Standard test gateway) environment and an online environment, the main environment is a main test environment, the STG environment is a pre-release environment, and the STG environment and the online environment share the same database.
Because a Host file without an extension name is preset in an internet Web system, the Host file is responsible for establishing a related database of some commonly used website domain names and IP addresses corresponding to the commonly used website domain names, when a browser inputs a required login website, the system firstly automatically searches the corresponding IP address from the Hosts file, once the corresponding website is found, the system immediately opens the corresponding webpage, if the corresponding website is not found, the system submits the website to a DNS domain name resolution server for IP address resolution, and if the website is found to be a shielded IP or domain name, the webpage is prohibited from being opened. When the test is required to be carried out in different environments, the Host file needs to be frequently replaced by hands, so that the test cannot be carried out autonomously, and the test efficiency is reduced. Before testing, the test environment is detected according to the execution case file, so that the Host file is updated without manual replacement, the whole test platform can operate autonomously, and the test efficiency is greatly improved.
The Host file and the Driver file can be updated simultaneously or separately, and can be adjusted according to actual application requirements.
Step 203, regenerating a new page configuration file according to the page configuration file, and judging whether the new page configuration file is the same as the original page configuration file;
if the page configuration files are the same, the original page configuration file is not replaced by the new page configuration file;
and if not, replacing the original page configuration file with the new page configuration file.
Because the Web test needs to be performed according to the steps of the automation case, which excessively depends on the front-end page elements, if the front-end page tags are slightly changed, a large number of cases may be reported incorrectly because the page elements cannot be located. Therefore, before testing, a new page configuration file is regenerated according to the generated page configuration file, the new page configuration file is compared with the original page configuration file, and if the new page configuration file is different from the original page configuration file, the new page configuration file is used for replacing the original page configuration file, so that the testing accuracy is improved, and the error probability is reduced.
In this embodiment, a new page configuration file is obtained through the CSS pseudo code and the tree table, where the new page configuration file includes a root element configuration file root.
Referring to fig. 5, generating a new page profile may include the following sub-steps:
substep S2031, extracting a DOM tree structure of a root node of the detected page according to the page configuration file;
substep S2032, forming a root element configuration file according to the DOM tree structure of the root node of the detected page;
substep S2033, obtaining the information of the tested element configuration file according to the root element configuration file;
and a substep S2034 of generating a measured element configuration file according to the measured element configuration file information.
And comparing the newly generated root element configuration file and the tested element configuration file with the old root element configuration file and the tested element configuration file to judge whether the page configuration file sends changes, and if the page configuration file sends changes, replacing the old page configuration file with the new page configuration file to avoid errors in testing caused by changes of the page configuration file.
Referring to fig. 6, the sub-step S2032 may further include the following sub-steps:
substep S20321, obtaining a root node of the page to be tested;
substep S20322, obtaining a unique identification node under the root node according to the root node;
and a substep S20323, obtaining a root element configuration file according to the unique identification node under the root node.
Referring to fig. 7, the sub-step S20321 may further include the following sub-steps:
substep S203211, obtaining a unique identifier under the root node according to the root node of the detected page, and determining whether the root node of the detected page has a unique ID identifier;
if the root node of the page to be tested has the unique ID, recording the unique ID, and acquiring the root node by using the ID;
if the root node of the tested page does not have the unique ID, judging whether the root node of the tested page has a CSS node or not;
and if the root node of the tested page has the CSS node, recording the CSS identification, and acquiring the root node by using the CSS identification.
If the root node of the tested page does not have a CSS node, an element array is positioned through the CSS, and then whether the element is uniquely positioned through the inclusion of a pseudo class is judged;
if the positioning can be carried out, recording positioning information to obtain a root node by the positioning information;
if the root node can not be positioned, positioning is carried out through the position label, and the position label is recorded, so that the root node is obtained through the position label.
The unique ID identification, the CSS identification, the positioning information or the position identification and the like are obtained and recorded in the root node, so that the root node is obtained according to the identification, each obtained root node has the identification in one-to-one correspondence, the condition that page elements cannot be identified can be effectively avoided, and the situation that the page elements can be recorded in a new page configuration file no matter what changes happen to a browser or a page to be tested midway is avoided, and the accuracy of subsequent testing is improved. If a new page configuration file is not generated, a front-end page label is slightly changed during testing, which may result in a large number of cases being reported by mistake because the page element cannot be located.
Referring to fig. 8, the sub-step S20322 may further include the following sub-steps:
and a substep S203221 of extracting a node having an ID identification under the root node root, recording the information of the node identified by the ID and the information of a father node thereof, and taking the father node information as a unique identification under the root node, thereby obtaining the unique identification node under the root node.
The node information of the node with the ID identification and the father node information thereof are recorded one by one and are used as the unique identification of the root node, so that the root node can obtain the identification and can be distinguished from other identifications.
Referring to fig. 9, the sub-step S2033 may further include the following sub-steps:
substep S20331, judge whether the present node has the unique ID label;
if the current node has the unique ID, recording the ID as the unique ID into the original tested element configuration file, and generating a new tested element configuration file so as to obtain a new page configuration file;
if the current node has no ID identification, judging whether the current node has a unique CSS identification;
if the current node has the unique CSS identification, the CSS identification is used as the unique identification to be recorded in the original element configuration file to be tested, and a new element configuration file to be tested is generated, so that a new page configuration file is obtained;
if the current node does not have the unique CSS identifier, acquiring a content element, a left brother node, a right brother node or a grandfather node with the unique identifier of the current node, recording the content element, the left brother node, the right brother node or the grandfather node with the unique identifier into an original element configuration file to be tested, and generating a new element configuration file to be tested so as to acquire a new page configuration file.
Since CSS identification is a language in which a user renders html or xml, CSS can bind style properties to a specified element node using its selector, i.e., a front-end developer can set each style on a page using CSS, no matter how complicated an element is positioned, since a developer can position and set a style, a tester can also position to the element node through CSS and then operate the element node. CSS often enables fast localization to complex element nodes through a compact syntax. And for an element node which can be uniquely located by ID or CSS, the element node is directly located by the ID and CSS label of the element node. If the element node which can not be uniquely positioned through the CSS can not be uniquely positioned, the element node needs to be positioned in a mode of a structure pseudo code and a content pseudo code, and the element node can be ensured to be uniquely positioned.
In this embodiment, the positioning mode may position the element node through the content pseudo code.
And 204, executing the test according to the automation use case, the page configuration file and the execution use case configuration file.
In this embodiment, the execution of the test includes performing three tests, namely a function test, a page CSS test, and a picture test, on the page to be tested, and the test items can be adjusted according to the application requirements, and the test sequence of the test items can be adjusted.
The functional test executes a basic functional test according to the steps of executing the case file and the automation case, and in this embodiment, the basic function may include a page title, a current URL of a page, a current source code of a page, a page element attribute, a page element value, and the like;
the page CSS test executes CSS label test according to the steps of the page configuration file and the automation case, the CSS label test can firstly acquire a label value so as to acquire the label value of the CSS, and then CSS parameter test of each dimensionality is carried out;
the picture test executes a picture similarity test according to the steps of the page configuration file and the automation case, and the picture similarity test can comprise the steps of comparing pictures based on a check value, the picture similarity test and a similarity algorithm.
Referring to fig. 10, the picture test for performing the picture similarity test according to the steps of the page configuration file and the automation case may include the following sub-steps:
substep S2041, obtaining an href link of the current element configuration file, sending an HTTP request to the href link to open the link, and determining whether a return value of the HTTP request is correct;
if the returned value of the transmitted HTTP request is wrong, sending a case error reporting instruction;
if the returned value of the sent HTTP request is correct, pulling the current page display picture P1 and the href configuration link picture P2, and judging whether the check values of P1 and P2 are the same;
if the check values are the same, determining that the pictures are the same;
if the check values are different, comparing the image entropy values of the pictures through a picture similarity algorithm;
if the entropy value is smaller than the entropy value, determining that the pictures are the same;
if the picture is larger than the entropy value, determining that the pictures are different, and sending a case error reporting indication.
In this embodiment, the verification values of the pictures P1 and P2 may be md5 values, sha1 values, crc verification, or the like.
In the embodiment, through three tests, the test range can be increased, and the test accuracy is greatly increased.
Referring to fig. 11, in this embodiment, a rerun mechanism is set during testing, where the rerun mechanism is a rerun test that fails three times;
if the first test and the second test fail to operate, judging whether the page element is in error report;
if the page element is not in error, the test is continued to be repeated and the test is continued;
if the page element is in error, judging whether the page element is the only ID identification;
if the ID is the only ID, the case is rerun and the test is continued;
if the unique ID identification is not the unique ID identification, the grandfather node or the root node css node of the unique ID identification is found, the position of the grandfather node is found through the contained pseudo code, the position information of the grandfather node is updated through a label folding method, and the grandfather node and the brother node are found for positioning.
And step 205, obtaining a test result, and generating a test report according to the test result.
The test report may include run element highlighting, error screenshots, error element marking, and error log analysis, among others. And finally, sending the test report to the mobile equipment of each tester, wherein the test report can be sent in an email or short message form.
In the embodiment of the invention, firstly, an artificial case is compiled by hands, then, a corresponding configuration file and a corresponding testing step are generated according to the artificial case, then, the browser information matched with the browser to be tested is updated according to the configuration file and the testing step, meanwhile, the testing environment is updated, the page elements are updated in time by utilizing the configuration file and the testing step, a new page element is generated, then, a testing result is generated according to the new page element, the configuration file and the testing step, and finally, a testing report is generated according to the testing result. The invention solves the mapping relation from manual test to automatic test, is more beneficial to systematized management of test cases and reduces the test cost; the problem of test case execution failure caused by Driver mismatching due to browser version upgrading is effectively solved; the problem that the element error report is caused by the fact that the page element of the front end is not obtained due to the fact that the page of the front end is changed is effectively solved; the defect that the automatic case can only be subjected to functional test is effectively solved, and front-end test is realized; the method can effectively position the error element, clearly indicate the error place when generating the error report, and can add the watermark on the error screenshot and the error element, analyze the error after the test, and facilitate the better management of the tester.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
The present invention further provides steps of an embodiment of a Web test method, in this embodiment, the Web test method is applied to a Web test platform, and controls the Web test platform to perform a test, where the Web test platform includes: the method comprises a case generation process, a file loading process, an element updating process, a testing process and a reporting process. The used process can be adjusted according to actual use requirements, and the test function and the test range of the test platform can be properly adjusted.
In this embodiment, the method specifically includes the following steps:
301, acquiring a manual test case by the case generation process, and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
the manual test case can be input by hands, and can be written by hands, and the manual test case written by hands can comprise basic test parameters, test URLs, case IDs, case keywords, case names, test steps, test data and the like;
the case generating process generates a case execution configuration file according to the basic test parameters, the case names and the case keywords, and the generated case execution file is a text.
The case generation process generates a page configuration file according to the test URL and the case ID, and the generated page configuration file is a Properties file;
and the case generation process generates an automatic case according to the test step and the test result, and the case generation process generates a jar file package of the automatic case. The input test result may be an expected test result written manually or a test result of a last test. The purpose of generating the test result into the automatic case is to compare the finally obtained test result with the input test result when the test result is finally obtained, so that technicians can conveniently analyze the test result after the test.
The manually written test cases are combined by using the case generation process, so that the manual case and the automatic case can be stored together, the management is more convenient, and the configuration file can be quickly generated; when the cross-platform compatibility test is carried out, the corresponding test environment can be directly loaded and selected, and the test efficiency is improved. Even a new person or a person unfamiliar with the code can reduce the error probability and the test cost.
And 302, the file loading process determines the version information of the browser to be tested according to the execution case file, and acquires and updates a Driver file matched with the version information of the browser to be tested.
Step 302 may also include the following sub-steps:
step S3021, reading the name of a target browser in the file loading process, where the target browser is a browser for executing a case configuration file to be tested;
in the substep S3022, the file device process obtains version information of the target browser based on the name of the target browser;
step S3023, the file device process searches Driver version information matched with the target browser version information from a preset mapping information table;
and a substep S3024, acquiring and loading a corresponding Driver file from a preset Driver application pool by the file device process according to the Driver version information.
The file loading process determines the version information of the browser to be tested according to the execution case file, so that the test version information of the test platform can be matched with the version information of the browser to be tested, and the version information of the browser to be tested is often not matched with the test platform due to the fact that the browser to be tested has an automatic upgrading function, various problems are caused, manual matching is needed, and the test efficiency is reduced. After a file loading process is added, automatic matching and updating can be carried out on the test platform, so that the test platform is matched with the browser to be tested.
Step 302 may also include the following sub-steps:
substep S3025, determining the tested environment by the file loading process according to the execution case file;
substep S3026, the file loading process obtains a corresponding Host file according to the tested environment;
and a substep S3027, replacing the Host file in the system by the file loading process according to the corresponding Host file.
In this embodiment, the test environment may include a main environment, an STG environment, and an online environment, where the main environment is a main environment for testing, the STG environment is a pre-release environment, and the STG environment and the online environment share the same database.
Because a Host file without an extension name is preset in a Web system, the Host file is responsible for establishing a related database of some commonly used website domain names and IP addresses corresponding to the commonly used website domain names, when a browser inputs a required login website, the system firstly automatically searches the corresponding IP address from the Hosts file, once the corresponding webpage is found, the system immediately opens the corresponding webpage, if the corresponding webpage is not found, the system submits the website to a DNS domain name resolution server for IP address resolution, and if the webpage is found to be a shielded IP or domain name, the webpage is prohibited from being opened. When the test is required to be carried out in different environments, the Host file needs to be frequently replaced by hands, so that the test cannot be carried out autonomously, and the test efficiency is reduced. Before testing, the test environment is detected by the file loading process according to the execution case file, so that the Host file is updated without manual replacement, the whole test platform can operate autonomously, and the test efficiency is greatly improved.
In addition, the Host file and the Driver file can be updated simultaneously or separately, and the updating sequence can be adjusted according to the actual application requirement.
Step 303, the element updating process regenerates a new page configuration file according to the page configuration file and judges whether the new page configuration file is the same as the original page configuration file;
if the page configuration files are the same, the original page configuration file is not replaced by the new page configuration file;
and if not, replacing the original page configuration file with the new page configuration file.
In this embodiment, the used test process needs to perform testing according to the steps of the automation case, and the automation case excessively depends on the front-end page elements, so that if the front-end page tags slightly change, a large number of cases may be reported incorrectly because the page elements cannot be located. Therefore, before testing, a new page configuration file is regenerated according to the page configuration file generated by the case generation process, the new page configuration file is compared with the page configuration file generated by the case generation process, if the new page configuration file is different from the page configuration file generated by the case generation process, the new page configuration file is used for replacing the old page configuration file, the testing accuracy is improved, and the error probability is reduced.
In this embodiment, the element updating process obtains a new page configuration file through the CSS pseudo code and the tree table, where the new page configuration file includes a root element configuration file root.
Substep S3031, the element updating process extracts the DOM tree structure of the root node of the tested page according to the page configuration file;
substep S3032, the element updating process forms a root element configuration file according to the DOM tree structure of the root node of the detected page;
substep S3033, the element updating process obtains the information of the configuration file of the element to be tested according to the root element configuration file;
and a substep S3034, generating a tested element configuration file by the element updating process according to the tested element configuration file information.
And comparing the two newly generated root element configuration files and the tested element configuration file with the old page configuration file to judge whether the page configuration file is changed or not, and if the page configuration file is changed, replacing the old page configuration file with the new page configuration file to avoid errors in the test process caused by the change of the page configuration file.
The sub-step S3032 may further include the sub-steps of:
substep S30321, the element updating process obtains the root node of the tested page;
substep S30322, the element updating process obtains the unique identification node under the root node according to the root node;
and a substep S30323, wherein the element updating process obtains the root element configuration file according to the unique identification node under the root node.
The sub-step S30321 may further include the sub-steps of:
in the substep S303211, the element updating process obtains a unique identifier under the root node according to the root node of the detected page, and determines whether the root node of the detected page has a unique ID identifier;
if the root node of the tested page has the unique ID, recording the unique ID, and acquiring the root node by the element updating process through the ID;
if the root node of the tested page does not have the unique ID, judging whether the root node of the tested page has a CSS node or not;
and if the root node of the tested page has the CSS node, recording the CSS identification, and acquiring the root node by the element updating process according to the CSS identification.
If the root node of the tested page has no CSS node, an element array is positioned through the CSS, and whether the element is uniquely positioned through the inclusion of a pseudo class is judged;
if the positioning can be carried out, recording positioning information, and acquiring a root node by the element updating process through the positioning information;
and if the element cannot be positioned, positioning through the position tag, recording the position tag, and acquiring the root node by the element updating process through the position tag.
The unique ID identification, the CSS identification, the positioning information or the position identification and the like are obtained and recorded in the root node, so that the root node is obtained according to the identification, each obtained root node has the identification in one-to-one correspondence, the condition that page elements cannot be identified can be effectively avoided, and the situation that the page elements cannot be identified can be recorded in a new page configuration file no matter what changes happen to a browser to be tested or a page to be tested midway, so that the accuracy of a test process in subsequent tests is improved. If a new page configuration file is not generated, a front-end page label is slightly changed during testing, which may result in a large number of cases being reported by mistake because the page element cannot be located.
The sub-step S30322 may further include the sub-steps of:
and a substep S303221, extracting the node with the ID identification under the root node root by the element updating process, recording the father node information of the node with the ID identification, and taking the father node information as the unique identification under the root node, thereby obtaining the unique identification node under the root node.
The node information of the node with the ID identification and the father node information thereof are recorded one by one and are used as the unique identification of the root node, so that the root node can obtain the identification and can be distinguished from other identifications.
Sub-step S3033 may further include the sub-steps of:
substep S30331, the element updating process judges whether the current node has a unique ID;
if the current node has the unique ID, the element updating process records the ID as the unique ID into the original tested element configuration file and generates a new tested element configuration file so as to obtain a new page configuration file;
if the current node has no ID identification, the element updating process judges whether the current node has a unique CSS identification;
if the current node has the unique CSS identifier, the element updating process records the CSS identifier as the unique identifier into the original tested element configuration file and generates a new tested element configuration file, so that a new page configuration file is obtained;
if the current node does not have the unique CSS identifier, the element updating process obtains the content element, the left brother node, the right brother node or the grandfather node with the unique identifier of the current node, records the content element, the left brother node, the right brother node or the grandfather node with the unique identifier into the original measured element configuration file, generates a new measured element configuration file, and accordingly obtains a new page configuration file.
Since CSS identification is a language in which a user renders html or xml, CSS can bind style properties to a specified element node using its selector, i.e., a front-end developer can set each style on a page using CSS, no matter how complicated an element is positioned, since a developer can position and set a style, a tester can also position to the element node through CSS and then operate the element node. CSS often enables fast localization to complex element nodes through a compact syntax. And for an element node which can be uniquely located by ID or CSS, the element node is directly located by the ID and CSS label of the element node. If the element node which can not be uniquely positioned through the CSS can not be uniquely positioned, the element node needs to be positioned in a mode of a structure pseudo code and a content pseudo code, and the element node can be ensured to be uniquely positioned.
The positioning mode can position the element node through the content pseudo code.
And 304, the test process executes the test according to the automation case, the page configuration file and the execution case configuration file, generates a test result and sends the test result to the report process.
The test process comprises a function process, a page CSS process and a picture process, and three tests of the function, the page CSS and the picture are respectively carried out on the tested page. The test items can be adjusted according to application requirements, and the test sequence of the test items can be adjusted
The functional process executes basic functional test according to the steps of executing the case file and the automation case, wherein the basic functions can comprise a page title, a current URL of a page, a current source code of the page, page element attributes, page element values and the like;
the page CSS process executes CSS label test according to the page configuration file and the steps of the automatic case, wherein the CSS label test can firstly acquire a label value so as to acquire the label value of the CSS, and then CSS parameter test of each dimension is carried out;
the picture process executes a picture similarity test according to the steps of the page configuration file and the automation case, wherein the picture similarity test can comprise the steps of comparing pictures based on a check value, the picture similarity test and a similarity algorithm.
The picture process executing the picture similarity test according to the steps of the page configuration file and the automation case may include the following substeps:
substep S3041, the picture process obtaining an href link of the current element configuration file, and sending an HTTP request to the href connection to open the link, and the picture process determining whether a return value of the HTTP request is correct;
if the HTTP request return value sent by the picture process is wrong, the picture process sends a use case error indication;
if the HTTP request return value sent by the picture process is correct, the picture process pulls the current page display picture P1 and the href configuration link picture P2, and whether the verification values of P1 and P2 are the same or not is judged;
if the check values are the same, the picture process determines that the pictures are the same;
if the check values are different, comparing the image entropy values of the images by the image process through an image similarity algorithm;
if the entropy value is smaller than the entropy value, the picture process determines that the pictures are the same;
if the entropy value is larger than the entropy value, the picture process determines that the pictures are different, and the picture process sends a use case error indication.
In the present embodiment, the verification values of the pictures P1 and P2 are md5 values.
The test process is used for testing, the test efficiency can be improved, and the test accuracy can be greatly improved through three tests.
And the testing process is provided with a re-running mechanism which is a failed re-running for three times;
if the first test and the second test fail to operate, the test process judges whether the page element is in error report;
if the page element is not in error, the test process continues to rerun and continues to test;
if the page element is in error, judging whether the page element is the only ID identification;
if the ID is the only ID, the case is rerun and the test is continued;
if the unique ID identification is not the unique ID identification, the grandfather node or the root node css node of the unique ID identification is found, the position of the grandfather node is found through the contained pseudo code, the position information of the grandfather node is updated through a label folding method, and the grandfather node and the brother node are found for positioning.
And 305, the report process acquires the test result of the test process and generates a test report according to the test result.
The test report may include run element highlighting, error screenshots, error element marking, and error log analysis, among others. And finally, the report process sends the test report to the mobile equipment of each tester, and the test report can be sent in an email or short message mode.
In the embodiment of the invention, a test request is received by a case generation process, then an artificial case is compiled by hands, then a corresponding configuration file and a test step are generated by the case generation process according to the artificial case, then a file loading process enables a tested browser to be matched with a test platform according to the configuration file and the test step, a test environment is matched with the test platform, the configuration file and the test step are sent to an element updating process, then the element updating process updates page elements in time by using the configuration file and the test step to generate new page elements, then an execution result is generated by the test process according to the new page elements, the configuration file and the test step, and finally the execution result is sent to a reporting process.
In the embodiment of the invention, the steps are executed by using each process, so that the working efficiency of the test platform can be improved, different work is executed among the processes, and the management is more convenient. Accordingly, the processes of the test platform can be adjusted, thereby adjusting the work among the processes.
The invention solves the mapping relation from manual test to automatic test, is more beneficial to systematized management of test cases and reduces the test cost; the problem of test case execution failure caused by Driver mismatching due to browser version upgrading is effectively solved; the problem that element errors are reported because page elements cannot be obtained due to the fact that a front-end page is changed is effectively solved; the defect that the automatic case can only be subjected to functional test is effectively solved, and front-end test is realized; the method can effectively position the error element, clearly indicate the error place when generating the error report, and can add the watermark on the error screenshot and the error element, analyze the error after the test, and facilitate the better management of the tester.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Furthermore, those of skill in the art will also appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the embodiments of the invention
The invention also provides a Web test platform, which comprises a case generation module, a file loading module and a test module;
the case generation module is used for acquiring a manual test case and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
the file loading module is used for determining version information of the browser to be tested according to the execution case file, and acquiring and updating a Driver file matched with the version information of the browser to be tested;
the test module is used for executing tests according to the automation use cases, the page configuration files and the execution use case configuration files.
In the implementation, the case generation module is used for acquiring a manual test case, the manual test case can be manually compiled by a person, and the manual test case comprises basic test parameters, a test URL, a case ID, case keywords, a case name, test steps and test data;
the case generating module is used for generating a case execution configuration file according to the basic test parameters, the case names and the case keywords;
the case generation module is used for generating a page configuration file according to the test URL and the case ID;
and the case generating module is used for generating an automatic case according to the testing step and the testing result.
In this implementation, the obtaining and updating the Driver file matched with the version information of the browser to be tested may include:
the file loading module is used for reading the name of a target browser, and the target browser is a browser which needs to be tested and executes a case configuration file;
the file device module is used for acquiring version information of the target browser according to the name of the target browser;
the file device module is used for searching Driver version information matched with the target browser version information from a preset mapping information table;
and the file device module is used for acquiring and loading a corresponding Driver file from a preset Driver application pool according to the Driver version information.
In this implementation, the obtaining and loading the Driver file matched with the version information of the browser to be tested may further include:
the file device module is used for determining a tested environment according to the execution test configuration file;
the file loading module is used for acquiring a corresponding Host file according to the tested environment;
and the file loading module is used for replacing the Host file in the system according to the corresponding Host file.
In this implementation, the test module includes a function module, a page CSS module, and a picture module, and the test module is configured to execute a test according to the automation use case, the page configuration file, and the execution use case configuration file;
the function module is used for executing a basic function test according to the steps of the execution case file and the automation case;
the page CSS module is used for executing CSS label test according to the page configuration file and the steps of the automatic case;
the picture module is used for executing the picture similarity test according to the steps of the page configuration file and the automation case.
In this implementation, the picture module is configured to execute the picture similarity test according to the steps of the page configuration file and the automation use case, and further includes:
the picture module is used for acquiring the href link of the current element configuration file, sending an HTTP request to open the link and judging whether the return value of the HTTP request is correct or not;
if the HTTP request return value sent by the picture module is wrong, the picture module sends a use case error indication;
if the HTTP request return value sent by the picture module is correct, the picture module pulls the current page display picture P1 and the href configuration link picture P2, and judges whether the verification values of P1 and P2 are the same;
if the check values are the same, the picture module determines that the pictures are the same;
if the check values are different, the picture module compares the image entropy values of the pictures through a picture similarity algorithm;
if the entropy value is smaller than the entropy value, the picture module determines that the pictures are the same;
if the entropy value is larger than the entropy value, the picture module determines that the pictures are different, and the picture module sends a use case error indication.
In this implementation, the test platform further includes an element update module;
the element updating module is used for regenerating a new page configuration file according to the page configuration file and judging whether the new page configuration file is the same as the original page configuration file or not;
if the page configuration files are the same, the original page configuration file is not replaced by the new page configuration file;
and if not, replacing the original page configuration file with the new page configuration file.
In this implementation, the page configuration file includes a root element configuration file and a measured element configuration file, and the element updating module obtains a new page configuration file through the CSS pseudo code and the tree table, including:
the element updating module is used for extracting a DOM tree structure of a root node of the tested page according to the page configuration file;
the element updating module is used for forming a root element configuration file according to the DOM tree structure of the root node of the tested page;
the element updating module is used for acquiring the information of the configuration file of the element to be tested according to the root element configuration file;
and the element updating module is used for generating a tested element configuration file according to the tested element configuration file information.
In this embodiment, the element update module is configured to form a root element configuration file according to a DOM tree structure of a root node of the detected page, and includes:
the element updating module is used for acquiring a root node of the page to be tested;
the element updating module is used for acquiring a unique identification node under the root node according to the root node;
and the element updating module is used for acquiring a root element configuration file according to the unique identification node under the root node.
In this implementation, the element updating module is configured to obtain a root node of the tested page, and further includes:
the element updating module judges whether a root node of a tested page has a unique ID (identity);
if the root node of the tested page has the unique ID, recording the unique ID, and acquiring the root node by the element updating module according to the ID;
if the root node of the tested page does not have the unique ID node, judging whether the root node of the tested page has a CSS node or not;
and if the root node of the tested page has the CSS node, recording the CSS identification, and acquiring the root node by the element updating module according to the CSS identification.
If the root node of the tested page has no CSS node, an element array is positioned through the CSS, and whether the element is uniquely positioned through the inclusion of a pseudo class is judged;
if the positioning can be carried out, recording positioning information, and acquiring a root node by the element updating module according to the positioning information;
and if the root node cannot be positioned, positioning through the position tag, recording the position tag, and acquiring the root node by the element updating module through the position tag.
In this implementation, the element updating module is configured to acquire, according to the root node, a unique identifier node under the root node, and further includes:
the element updating module is used for extracting nodes with ID identification under root nodes, identifying the information of the nodes through the ID, recording father node information of the nodes, and taking the father node information as the unique identification under the root nodes, so that the unique identification nodes under the root nodes are obtained.
In this implementation, the generating, by the element update module, the measured element profile according to the measured element profile information includes:
the element updating module judges whether the current node has a unique ID mark;
if the current node has the unique ID, the element updating module records the ID as the unique ID into the original tested element configuration file and generates a new tested element configuration file so as to obtain a new page configuration file;
if the current node has no ID identification, the element updating module judges whether the current node has a unique CSS identification;
if the current node has the unique CSS identifier, the element updating module records the CSS identifier as the unique identifier into the original tested element configuration file and generates a new tested element configuration file, so that a new page configuration file is obtained;
if the current node does not have the unique CSS identifier, the element updating module obtains a content element, a left brother node, a right brother node or a grandfather node with the unique identifier of the current node, records the content element, the left brother node, the right brother node or the grandfather node with the unique identifier in an original measured element configuration file, generates a new measured element configuration file, and accordingly obtains a new page configuration file.
In this implementation, the test platform further includes a reporting module, where the reporting module is configured to obtain a test result of the test module, and generate a test report according to an execution result of the test module.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
An embodiment of the present invention further provides a device, including:
one or more processors; and
one or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform methods as described in embodiments of the invention.
Embodiments of the invention also provide one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the methods described in embodiments of the invention.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The above detailed description is given to the Web test method and the Web test platform provided by the present invention, and the specific examples are applied herein to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (15)

1. A method for testing a Web, the method comprising:
acquiring a manual test case, and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
determining version information of the browser to be tested according to the execution case configuration file, and acquiring and updating a Driver file matched with the version information of the browser to be tested;
executing a test according to the automatic use case, the page configuration file and the execution use case configuration file;
the acquiring and updating of the Driver file matched with the version information of the browser to be tested further comprises:
determining a tested environment according to the execution case configuration file;
acquiring a corresponding Host file according to the tested environment;
and replacing the Host file in the system according to the corresponding Host file.
2. The method of claim 1, wherein the manual test case comprises basic test parameters, a test URL, a case ID, case keywords, a case name, test steps, test data; the executing the test according to the automatic use case, the page configuration file and the execution use case configuration file comprises the following steps:
generating a case execution configuration file according to the basic test parameters, the case names and the case keywords;
generating a page configuration file according to the test URL and the case ID;
and generating an automatic case according to the test steps and the test result.
3. The method according to claim 1, wherein the obtaining and updating the Driver file matching the version information of the browser under test comprises:
reading the name of a target browser, wherein the target browser is a browser which needs to be tested and executes a case configuration file;
acquiring version information of the target browser according to the name of the target browser;
searching Driver version information matched with the target browser version information from a preset mapping information table;
and acquiring and loading a corresponding Driver file from a preset Driver application pool according to the Driver version information.
4. The method of claim 1, wherein executing tests according to the automation use case, page configuration file, and execution use case configuration file comprises:
executing a basic function test according to the steps of the execution case configuration file and the automation case;
performing CSS label test according to the steps of the page configuration file and the automation case;
and executing the picture similarity test according to the steps of the page configuration file and the automatic case.
5. The method of claim 4, wherein the picture similarity test is performed according to the steps of the page configuration file and the automation case, and further comprising:
acquiring an href link of the current element configuration file, sending an HTTP request to the href link to open the link, and judging whether a return value of the HTTP request is correct or not;
if the returned value of the transmitted HTTP request is wrong, sending a case error reporting instruction;
if the returned value of the sent HTTP request is correct, pulling the current page display picture P1 and the href configuration link picture P2, and judging whether the check values of P1 and P2 are the same;
if the check values are the same, determining that the pictures are the same;
if the check values are different, comparing the image entropy values of the pictures by a picture similarity calculation method;
if the entropy value is smaller than the entropy value, determining that the pictures are the same;
if the picture is larger than the entropy value, determining that the pictures are different, and sending a case error reporting indication.
6. The method of claim 1, further comprising:
regenerating a new page configuration file according to the page configuration file, and judging whether the new page configuration file is the same as the original page configuration file or not;
if the page configuration files are the same, replacing the original page configuration file with the new page configuration file;
and if not, replacing the original page configuration file with the new page configuration file.
7. The method of claim 6, wherein obtaining a new page profile via CSS pseudo code and a tree table, the page profile comprising a root element profile and a measured element profile, the obtaining a new page profile comprising:
extracting a DOM tree structure of a root node of the tested page according to the page configuration file;
forming a root element configuration file according to the DOM tree structure of the root node of the page to be tested;
acquiring the information of the configuration file of the element to be tested according to the root element configuration file;
and generating a tested element configuration file according to the tested element configuration file information.
8. The method of claim 7, wherein composing the root element configuration file according to the DOM tree structure of the root node of the page under test comprises:
acquiring a root node of a page to be tested;
acquiring a unique identification node under a root node according to the root node;
and acquiring a root element configuration file according to the unique identification node under the root node.
9. The method of claim 8, wherein obtaining a root node of a page under test further comprises:
acquiring a unique identifier under a root node according to the root node of the detected page, and judging whether the root node of the detected page has a unique ID identifier or not;
if the root node of the tested page has the unique ID, recording the unique ID, and acquiring the root node by using the ID;
if the root node of the tested page does not have the unique ID node, judging whether the root node of the tested page has a CSS node or not;
if the root node of the tested page has a CSS node, recording a CSS identifier, and acquiring the root node by using the CSS identifier;
if the root node of the tested page has no CSS node, an element array is positioned through the CSS, and whether the element is uniquely positioned through the inclusion of a pseudo class is judged;
if the positioning can be carried out, recording positioning information, and acquiring a root node by using the positioning information;
if the root node can not be positioned, positioning is carried out through the position label, and the position label is recorded, so that the root node is obtained through the position label.
10. The method according to claim 8, wherein obtaining the unique identification node under the root node according to the root node further comprises:
and extracting nodes with ID identification under root nodes, identifying the information of the nodes through the ID, recording father node information of the nodes, and taking the father node information as the unique identification under the root nodes so as to obtain the unique identification nodes under the root nodes.
11. The method of claim 7, wherein generating a measured element profile based on the measured element profile information comprises:
judging whether the current node has a unique ID (identity);
if the current node has the unique ID, recording the ID as the unique ID into the original tested element configuration file, and generating a new tested element configuration file so as to obtain a new page configuration file;
if the current node has no ID identification, judging whether the current node has a unique CSS identification;
if the current node has the unique CSS identification, the CSS identification is used as the unique identification to be recorded in the original element configuration file to be tested, and a new element configuration file to be tested is generated, so that a new page configuration file is obtained;
if the current node does not have the unique CSS identifier, acquiring a content element, a left brother node, a right brother node or a grandfather node with the unique identifier of the current node, recording the content element, the left brother node, the right brother node or the grandfather node with the unique identifier into an original element configuration file to be tested, and generating a new element configuration file to be tested so as to acquire a new page configuration file.
12. The method of claim 1, further comprising obtaining test results and generating a test report based on the test results.
13. A Web test platform comprises a case generation module, a file loading module and a test module;
the case generation module is used for acquiring a manual test case and generating an automatic case, a page configuration file and an execution case configuration file according to the manual test case;
the file loading module is used for determining version information of the browser to be tested according to the execution case configuration file, and acquiring and updating a Driver file matched with the version information of the browser to be tested;
the test module is used for executing tests according to the automation use cases, the page configuration files and the execution use case configuration files;
the file loading module is further configured to:
determining a tested environment according to the execution case configuration file;
acquiring a corresponding Host file according to the tested environment;
and replacing the Host file in the system according to the corresponding Host file.
14. A Web test apparatus, comprising:
one or more processors; and
one or more machine-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 1-12.
15. One or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the method of any one of claims 1-12.
CN201910161259.7A 2019-03-04 2019-03-04 Web test method and test platform Active CN109902016B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910161259.7A CN109902016B (en) 2019-03-04 2019-03-04 Web test method and test platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910161259.7A CN109902016B (en) 2019-03-04 2019-03-04 Web test method and test platform

Publications (2)

Publication Number Publication Date
CN109902016A CN109902016A (en) 2019-06-18
CN109902016B true CN109902016B (en) 2022-06-14

Family

ID=66946352

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910161259.7A Active CN109902016B (en) 2019-03-04 2019-03-04 Web test method and test platform

Country Status (1)

Country Link
CN (1) CN109902016B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110737599A (en) * 2019-10-18 2020-01-31 付彪 Front-end automatic regression testing system and method based on picture comparison technology
CN112711525B (en) * 2019-10-25 2023-12-26 中国移动通信集团浙江有限公司 Collaborative testing method and device for UI test and interface test and computing equipment
CN111177014B (en) * 2020-02-24 2023-02-24 重庆长安新能源汽车科技有限公司 Software automatic test method, system and storage medium
CN111367802B (en) * 2020-02-29 2024-06-25 中国平安财产保险股份有限公司 Web automatic test method, device and computer readable storage medium
CN111414154A (en) * 2020-03-31 2020-07-14 中国建设银行股份有限公司 Method and device for front-end development, electronic equipment and storage medium
CN112100359B (en) * 2020-10-14 2024-09-03 北京嘀嘀无限科技发展有限公司 Test case searching method, device, equipment and storage medium
CN112231213A (en) * 2020-10-16 2021-01-15 广州助蜂网络科技有限公司 Web automatic testing method, system, storage medium and terminal equipment
CN112559318B (en) * 2020-11-02 2024-07-26 浙江诺诺网络科技有限公司 Test case generation method and device, electronic equipment and storage medium
CN112346984A (en) * 2020-11-24 2021-02-09 中信银行股份有限公司 Web end comprehensive test method and system
CN114676034B (en) * 2020-12-24 2024-07-09 腾讯科技(深圳)有限公司 Test method and device and computer equipment
CN112685300A (en) * 2020-12-28 2021-04-20 京东数字科技控股股份有限公司 Webpage automatic testing method and device, electronic equipment and readable storage medium
CN113176914A (en) * 2021-06-03 2021-07-27 上海中通吉网络技术有限公司 Modularized testing tool based on automatic Web end

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779091A (en) * 2012-06-18 2012-11-14 中兴通讯股份有限公司 Test transformation method and test transformation device
CN104252410A (en) * 2013-06-27 2014-12-31 阿里巴巴集团控股有限公司 Method and equipment for testing control in page
CN108694118A (en) * 2017-04-11 2018-10-23 北京京东尚科信息技术有限公司 A kind of application testing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020097268A1 (en) * 2001-01-22 2002-07-25 Dunn Joel C. Method, system, and program for a platform-independent, browser-based, client-side, test automation facility for verifying web site operation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779091A (en) * 2012-06-18 2012-11-14 中兴通讯股份有限公司 Test transformation method and test transformation device
CN104252410A (en) * 2013-06-27 2014-12-31 阿里巴巴集团控股有限公司 Method and equipment for testing control in page
CN108694118A (en) * 2017-04-11 2018-10-23 北京京东尚科信息技术有限公司 A kind of application testing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
关于Selenium WebDriver自动化测试框架设计与实现;邓志勇;《数字化用户》;20181231;第1-3页 *

Also Published As

Publication number Publication date
CN109902016A (en) 2019-06-18

Similar Documents

Publication Publication Date Title
CN109902016B (en) Web test method and test platform
US10108535B2 (en) Web application test script generation to test software functionality
US7475286B2 (en) System and method for updating end user error reports using programmer defect logs
CN110287109B (en) Protocol interface testing method and device, computer equipment and storage medium thereof
US9419884B1 (en) Intelligent automated testing method for restful web services
JP3946057B2 (en) Consistency inspection support method and consistency inspection support system
US9880832B2 (en) Software patch evaluator
US9864793B2 (en) Language tag management on international data storage
CN111090452A (en) Service environment switching method and computer-readable storage medium
CN112540924A (en) Interface automation test method, device, equipment and storage medium
CN111552632B (en) Interface testing method and device
CN112241370B (en) API interface class checking method, system and device
CN111444101A (en) Method and device for automatically creating product test defects
US20050137844A1 (en) Method for generating a language-independent regression test script
CN113312260B (en) Interface test method, device, equipment and storage medium
CN112069073A (en) Test case management method, terminal and storage medium
CN111654495B (en) Method, apparatus, device and storage medium for determining traffic generation source
CN115658452A (en) Buried point checking method, buried point checking device, readable storage medium and electronic equipment
CN115033481A (en) Method and device for automatic test code generation based on browser access and computer equipment
CN111324718A (en) Conversation flow testing method and device, electronic equipment and readable storage medium
CN112540925A (en) New characteristic compatibility detection system and method, electronic device and readable storage medium
CN109508203B (en) Method, device and system for determining version consistency
CN116069667A (en) Test case auxiliary positioning method and device based on code analysis
CN116737535A (en) Interface test method, device, computer equipment and storage medium
CN116166533A (en) Interface testing method, device, terminal equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant