CN107678943A - The page automated testing method of abstract page object - Google Patents
The page automated testing method of abstract page object Download PDFInfo
- Publication number
- CN107678943A CN107678943A CN201710783624.9A CN201710783624A CN107678943A CN 107678943 A CN107678943 A CN 107678943A CN 201710783624 A CN201710783624 A CN 201710783624A CN 107678943 A CN107678943 A CN 107678943A
- Authority
- CN
- China
- Prior art keywords
- page
- data
- key
- tested
- json data
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a kind of page automated testing method of abstract page object;1) json data are abstracted into test page element;2) test page operation is abstracted as four kinds of forms:Increase, delete, change, look into;3) the json data being abstracted are parsed, come positioning webpage element and the operation for being increased, deleting, change, looking into by using java code parsing json data:4) uniformity is carried out to operating result to assert.If test page object changes, it is only necessary to changes json data, code logic does not have to write again, even without modification, it is possible to realizes the ui automatic tests to another test page, has greatly reinforced the portability of rate of code reuse and test frame.
Description
Technical field
The present invention relates to page technical field of measurement and test, and in particular to a kind of page automatic test side of abstract page object
Method.
Background technology
Page automatic test is that a kind of input is write with income than relatively low automatic test mode, test case
Cost is high, and maintenance cost is high, and because the technical implementation way of web page is varied, the html form that shows also respectively has
Difference, so lack a kind of effective method of unification realizes efficiency to solve the automation of web products;
The page automated test tool for comparing main flow in the industry has selenium, it be by the html structures of the page or
A series of element that attribute comes in positioning webpage, by realizing that page operations (are such as clicked on, defeated with browser kernel interactive interfacing
Enter, obtain text message etc.), but the different pages, element are had nothing in common with each other, industry does not have a kind of method and can used equally at present
Mode obtain different elements.
Problem of the prior art is as follows:
1st, because page elements are had nothing in common with each other, so one different page of test every time, is required for writing java again
Code carrys out location element, thus more many repeated work.
2nd, because each web products business is different, so test logic is also had nothing in common with each other, so the step of test case is also each
There is difference, so that the reusable rate of test code is approximately equal to 0.
The content of the invention
The present invention solves same type or is laid out similar web page realizes all web products by portion test code
Automatic test technical problem.
The technical solution adopted by the present invention is:
A kind of page automated testing method of abstract page object, comprises the following steps:
Tested page elements are abstracted as JSON data;
The JSON data being abstracted by using JAVA code parsings are positioned tested page elements and operated;
Uniformity is carried out to operating result to assert.
Further, the JSON data replace with XML data.
Further, the JSON data include increasing, deleting, changing, looking into four kinds of forms.
Further, the operation includes the operation for increasing, deleting, change, looking into.
Further, for different tested page elements, realized by changing JSON data to the tested page member of difference
The UI automatic tests of element.
Further, the JSON data are specific as follows:
String menuBody={ " data source control ":[" data source control ", " field management "], " page management ":
[" page management "], " form subscription ":[" subscription list "] };
String controlBody=" { " data source control ":" { " increases data source newly ":" O data source ", " inquiry ":″
[" input title ", " input description ", { " input application system ":[" whole systems ", " opal ", " report "] }] }, " field
Management ":" { " new field ":" O field ", " inquiry ":" [" inputs title ", { " selection data source ":[" is complete
Portion ", " * "] }] }, " page management ":" { " inquires about ":" [" inputs title ", { " selection state ":[" whole states ", " effective ", "
Invalid "] }, { " input application system ":[" whole systems ", " opal ", " report "] }] }, " subscription list ":" { " inquires about ":″
[" input mailbox "] } } ";
String tableBody=" { " data source control ":" [" title ", " description ", " application system ", " type ", "
Server ", " supporting assembly ", " state ", " { " operates ":[" modification ", " list of fields ", " obtaining nearest data "] }], " field
Management ":" [" data source ", " field ", " field type ", " description ", " sequence ", " state ", " { " operates ":[" repair
Change "]] } ";
String data sources=" ... ";
String fields=" ... ";
Wherein, menuBody is tested page menus column, and controlBody is tested page operation column, and tableBody is
Tested page tabular.
Further, the JSON data that the JAVA code parsings are abstracted specifically include following steps:
Traversing operation column, the size for making tested page menus column key is i, wherein, key is keyword, and size is size;
The size for making i-th of key array value is j, and wherein value is value, and j-th of value is named as V;
Judge key of the tested page operation column with the presence or absence of value as V:If it does, obtain the son for the value that key is V
key;If it does not exist, then there is exception, check whether JSON data are correct;
After the sub- key for obtaining the value that key is V, tested page elements are positioned according to sub- key text;
Tested page elements are clicked on, and judge key value whether with 0 beginning:If it is, with String localization key elements
And click on;If it is not, it is JSON arrays to judge whether;
After String localization key elements and click, find the JSON data of content of text behind entitled 0 and parse;According to
Analysis result is clicked on or input text;Asserted according to the JSON data of tested page tabular;
Judge whether it is JSON arrays:If it is not, then there is exception, check whether JSON data are correct;If it is, with
String localization key elements simultaneously travel through array, and with the element in String localization array, input test data, and key is clicked on, root
Asserted according to the JSON data of tested page tabular.
Further, operating result progress uniformity is asserted and specifically includes following steps:
If operation is to increase, being tested page tabular increases a record, and judges increased record field and input
Whether test data matches one by one;
If operation is to delete, it is tested page tabular and reduces by a record, and confirm the record for the record and reduction deleted
It is same;
If operation is to change, page tabular record quantity is constant, changes respective field and the test data of input are tested
Matching;
If operation is to look into, tested page tabular record quantity matches with Query Result.
Beneficial effects of the present invention are as follows:
1st, the page is abstracted as JSON data, the solution to any JSON data can be achieved with by same JAVA codes
Analysis;
2nd, all operations of web page are all that additions and deletions change the operation looked into fact after all, it is all to these four operate into
Row encapsulation, and JSON data are combined, can greatly improve test rate of code reuse.
Brief description of the drawings
Fig. 1 is the tested page 1 of the present invention.
Fig. 2 is the tested page 2 of the present invention.
Fig. 3 is the tested page 3 of the present invention.
Fig. 4 is the tested page 4 of the present invention.
Fig. 5 is the JSON data flowcharts that JAVA code parsings are abstracted.
Embodiment
The invention solves be exactly to take out a kind of homogeneous mode to solve the automatic test of the different pages:
1st, page elements are abstracted into JSON data (Java Script Object Notation, JS object tags, is
A kind of data interchange format of lightweight);
2nd, page operation is abstracted as four kinds of forms:Increase, delete, change, look into;
3rd, the JSON data being abstracted are parsed, carrys out positioning webpage element by using JAVA code parsing JSON data and goes forward side by side
The operation that row increases, deleted, changing, looking into;
4th, uniformity is carried out to operating result to assert.
Hereinafter, the present invention is further elaborated in conjunction with the accompanying drawings and embodiments.
1st, tested page elements are abstracted as JSON data (can be regarded as page configuration), as Figure 1-Figure 4, can
It is abstracted as following JSON data:
String menuBody={ " data source control ":[" data source control ", " field management "], " page management ":
[" page management "], " form subscription ":[" subscription list "] };
String controlBody=" { " data source control ":" { " increases data source newly ":" O data source ", " inquiry ":″
[" input title ", " input description ", { " input application system ":[" whole systems ", " opal ", " report "] }] }, " field
Management ":" { " new field ":" O field ", " inquiry ":" [" inputs title ", { " selection data source ":[" is complete
Portion ", " * "] }] }, " page management ":" { " inquires about ":" [" inputs title ", { " selection state ":[" whole states ", " effective ", "
Invalid "] }, { " input application system ":[" whole systems ", " opal ", " report "] }] }, " subscription list ":" { " inquires about ":″
[" input mailbox "] } } ";
String tableBody=" { " data source control ":" [" title ", " description ", " application system ", " type ", "
Server ", " supporting assembly ", " state ", " { " operates ":[" modification ", " list of fields ", " obtaining nearest data "] }], " field
Management ":" [" data source ", " field ", " field type ", " description ", " sequence ", " state ", " { " operates ":[" repair
Change "]] } ";
String data sources=" ... ";
String fields=" ... ";
Wherein, menuBody is menu bar, and controlBody is east side operation column, and tableBody is lower right-hand side table
Lattice.
2nd, JAVA code parsings JSON data, as shown in figure 5, comprising the following steps that:
Traversing operation column, the size for making tested page menus column key is i, wherein, key is keyword, and size is size;
The size for making i-th of key array value is j, and wherein value is value, and j-th of value is named as V;
Judge key of the tested page operation column with the presence or absence of value as V:If it does, obtain the son for the value that key is V
key;If it does not exist, then there is exception, check whether JSON data are correct;
After the sub- key for obtaining the value that key is V, tested page elements are positioned according to sub- key text;
Tested page elements are clicked on, and judge key value whether with 0 beginning:If it is, with String localization key elements
And click on;If it is not, it is JSON arrays to judge whether;
After String localization key elements and click, find the JSON data of content of text behind entitled 0 and parse;According to
Analysis result completes basic page operation (clicking on or input text etc.);Broken according to the JSON data of tested page tabular
Speech;
Judge whether it is JSON arrays:If it is not, then there is exception, check whether JSON data are correct;If it is, with
String localization key elements simultaneously travel through array, and with the element in String localization array, input test data, and key is clicked on, root
Asserted according to the JSON data of tested page tabular.
3rd, JSON data are asserted
If increasing, then tableBody lists increase a record, and judge increased record field and the test of input
Data match one by one;
If deleting, then tableBody lists reduce by a record, and confirm that the record of deletion and the record of reduction are same
One;
If changing, then tableBody records quantity is constant, and the respective field changed matches with the test data inputted;
If looking into, then tableBody records quantity and matched with Query Result
4th, in this way, as test page element changes, it is only necessary to change JSON data, code logic does not have to write again, even
Without modification, it is possible to realize UI (User Interface, user interface) automatic test to another test page, greatly
The big portability for strengthening rate of code reuse and test frame.
The present invention can be changed to XML (eXtensible Markup using different programming languages, JSON data
Language, extending mark language) data or other similar data formats.
Although the present invention is disclosed as above with preferred embodiment, it is not for limiting the present invention, any this area
Technical staff without departing from the spirit and scope of the present invention, may be by the methods and technical content of the disclosure above to this hair
Bright technical scheme makes possible variation and modification, therefore, every content without departing from technical solution of the present invention, according to the present invention
Any simple modifications, equivalents, and modifications made to above example of technical spirit, belong to technical solution of the present invention
Protection domain.
Claims (8)
1. a kind of page automated testing method of abstract page object, it is characterised in that comprise the following steps:
Tested page elements are abstracted as JSON data;
The JSON data being abstracted by using JAVA code parsings are positioned tested page elements and operated;
Uniformity is carried out to operating result to assert.
2. a kind of page automated testing method of abstract page object as claimed in claim 1, it is characterised in that described
JSON data replace with XML data.
3. a kind of page automated testing method of abstract page object as claimed in claim 1, it is characterised in that described
JSON data include increasing, deleting, changing, looking into four kinds of forms.
A kind of 4. page automated testing method of abstract page object as claimed in claim 3, it is characterised in that the behaviour
Make to include the operation for increasing, deleting, change, looking into.
5. a kind of page automated testing method of abstract page object as claimed in claim 4, it is characterised in that for not
Same tested page elements, realized by changing JSON data to the different UI automatic tests for being tested page elements.
6. a kind of page automated testing method of abstract page object as claimed in claim 5, it is characterised in that described
JSON data are specific as follows:
String menuBody={ " data source control ":[" data source control ", " field management "], " page management ":[" page
Facial canal manages "], " form subscription ":[" subscription list "] };
String controlBody=" { " data source control ":" { " increases data source newly ":" O data source ", " inquiry ":" [" is defeated
Enter title ", " input description ", { " input application system ":[" whole systems ", " opal ", " report "] }] }, " field pipe
Reason ":" { " new field ":" O field ", " inquiry ":" [" inputs title ", { " selection data source ":[" whole ", " * "] }] }, "
Page management ":" { " inquires about ":" [" inputs title ", { " selection state ":[" whole states ", " effective ", " invalid "] }, it is { " defeated
Enter application system ":[" whole systems ", " opal ", " report "] }] }, " subscription list ":" { " inquires about ":" [" inputs postal
Case "] } } ";
String tableBody=" { " data source control ":" [" title ", " description ", " application system ", " type ", " service
Device ", " supporting assembly ", " state ", " { " operates ":[" modification ", " list of fields ", " obtaining nearest data "] }], " field pipe
Reason ":" [" data source ", " field ", " field type ", " description ", " sequence ", " state ", " { " operates ":[" modification "] }] } ";
String data sources=" ... ";
String fields=" ... ";
Wherein, menuBody is tested page menus column, and controlBody is tested page operation column, and tableBody is tested
Page tabular.
A kind of 7. page automated testing method of abstract page object as described in claim 5 or 6, it is characterised in that institute
State the JSON data that JAVA code parsings are abstracted and specifically include following steps:
Traversing operation column, the size for making tested page menus column key is i, wherein, key is keyword, and size is size;
The size for making i-th of key array value is j, and wherein value is value, and j-th of value is named as V;
Judge key of the tested page operation column with the presence or absence of value as V:If it does, obtain the sub- key for the value that key is V;Such as
Fruit is not present, then exception occurs, checks whether JSON data are correct;
After the sub- key for obtaining the value that key is V, tested page elements are positioned according to sub- key text;
Tested page elements are clicked on, and judge key value whether with 0 beginning:If it is, with String localization key elements and point
Hit;If it is not, it is JSON arrays to judge whether;
After String localization key elements and click, find the JSON data of content of text behind entitled 0 and parse;According to parsing
As a result click on or input text;Asserted according to the JSON data of tested page tabular;
Judge whether it is JSON arrays:If it is not, then there is exception, check whether JSON data are correct;If it is, with text
Positioning key elements simultaneously travel through array, and with the element in String localization array, input test data, and key is clicked on, according to quilt
The JSON data for surveying page tabular are asserted.
8. a kind of page automated testing method of abstract page object as claimed in claim 4, it is characterised in that to operation
As a result progress uniformity, which is asserted, specifically includes following steps:
If operation is to increase, being tested page tabular increases a record, and judges increased record field and the test of input
Whether data match one by one;
If operation is to delete, it is tested page tabular and reduces by a record, and confirms that the record of deletion and the record of reduction are same
One;
If operation is to change, tested page tabular record quantity is constant, and the respective field changed matches with the test data inputted;
If operation is to look into, tested page tabular record quantity matches with Query Result.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710783624.9A CN107678943B (en) | 2017-09-01 | 2017-09-01 | Page automatic testing method of abstract page object |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710783624.9A CN107678943B (en) | 2017-09-01 | 2017-09-01 | Page automatic testing method of abstract page object |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107678943A true CN107678943A (en) | 2018-02-09 |
CN107678943B CN107678943B (en) | 2020-10-30 |
Family
ID=61136121
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710783624.9A Active CN107678943B (en) | 2017-09-01 | 2017-09-01 | Page automatic testing method of abstract page object |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107678943B (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108304329A (en) * | 2018-02-13 | 2018-07-20 | 论客科技(广州)有限公司 | A kind of testing example design method, apparatus, terminal and readable storage medium storing program for executing |
CN109240933A (en) * | 2018-09-28 | 2019-01-18 | 四川长虹电器股份有限公司 | A kind of tables of data operating result asserts method |
CN109522225A (en) * | 2018-11-09 | 2019-03-26 | 网宿科技股份有限公司 | A kind of automatic test asserts method and device, test platform and storage medium |
CN109634660A (en) * | 2018-10-16 | 2019-04-16 | 深圳壹账通智能科技有限公司 | Program structure method for visualizing, equipment, storage medium and device |
CN110457616A (en) * | 2019-07-24 | 2019-11-15 | 万达信息股份有限公司 | A kind of method that webpage consistency is shown under isomery CPU system |
CN111209204A (en) * | 2020-01-06 | 2020-05-29 | 杭州涂鸦信息技术有限公司 | JSON-based web automatic testing method, system and device |
CN112612563A (en) * | 2020-12-16 | 2021-04-06 | 上海哔哩哔哩科技有限公司 | Page test data generation method and device and computer equipment |
CN113791968A (en) * | 2021-08-10 | 2021-12-14 | 武汉光庭信息技术股份有限公司 | UI automation test method, system, electronic equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103049369A (en) * | 2011-10-14 | 2013-04-17 | 阿里巴巴集团控股有限公司 | Automated testing method and system |
-
2017
- 2017-09-01 CN CN201710783624.9A patent/CN107678943B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103049369A (en) * | 2011-10-14 | 2013-04-17 | 阿里巴巴集团控股有限公司 | Automated testing method and system |
Non-Patent Citations (1)
Title |
---|
蓝雨.BERNERS: "前端与服务器端技术探讨", 《• HTTPS://WWW.CNBLOGS.COM/9988/P/5201347.HTML》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108304329A (en) * | 2018-02-13 | 2018-07-20 | 论客科技(广州)有限公司 | A kind of testing example design method, apparatus, terminal and readable storage medium storing program for executing |
WO2019157884A1 (en) * | 2018-02-13 | 2019-08-22 | 论客科技(广州)有限公司 | Test case design method, apparatus and terminal, and readable storage medium |
CN109240933A (en) * | 2018-09-28 | 2019-01-18 | 四川长虹电器股份有限公司 | A kind of tables of data operating result asserts method |
CN109240933B (en) * | 2018-09-28 | 2022-07-26 | 四川虹微技术有限公司 | Data table operation result assertion method |
CN109634660A (en) * | 2018-10-16 | 2019-04-16 | 深圳壹账通智能科技有限公司 | Program structure method for visualizing, equipment, storage medium and device |
CN109522225A (en) * | 2018-11-09 | 2019-03-26 | 网宿科技股份有限公司 | A kind of automatic test asserts method and device, test platform and storage medium |
CN110457616A (en) * | 2019-07-24 | 2019-11-15 | 万达信息股份有限公司 | A kind of method that webpage consistency is shown under isomery CPU system |
CN110457616B (en) * | 2019-07-24 | 2024-02-13 | 万达信息股份有限公司 | Method for displaying web page consistency under heterogeneous CPU system |
CN111209204A (en) * | 2020-01-06 | 2020-05-29 | 杭州涂鸦信息技术有限公司 | JSON-based web automatic testing method, system and device |
CN111209204B (en) * | 2020-01-06 | 2023-09-22 | 杭州涂鸦信息技术有限公司 | Automatic web testing method based on JSON, system and device thereof |
CN112612563A (en) * | 2020-12-16 | 2021-04-06 | 上海哔哩哔哩科技有限公司 | Page test data generation method and device and computer equipment |
CN113791968A (en) * | 2021-08-10 | 2021-12-14 | 武汉光庭信息技术股份有限公司 | UI automation test method, system, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN107678943B (en) | 2020-10-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107678943A (en) | The page automated testing method of abstract page object | |
US20230334032A1 (en) | Creating data in a data store using a dynamic ontology | |
US11645139B2 (en) | Software testing | |
US20210318851A1 (en) | Systems and Methods for Dataset Merging using Flow Structures | |
CN109101652B (en) | Label creating and managing system | |
US9678719B1 (en) | System and software for creation and modification of software | |
AU2009238294B2 (en) | Data transformation based on a technical design document | |
CN106528129A (en) | Web application interface generation system and method | |
CN102043716A (en) | Automatic software testing method based on business driving | |
US20170322944A1 (en) | Automatic entry of suggested translated terms in an online application program | |
CN101246495A (en) | Method for constructing query scheme and executing data query and statistics | |
US20160154779A1 (en) | Automatic modeling of column and pivot table layout tabular data | |
US11775759B2 (en) | Systems and methods for training and evaluating machine learning models using generalized vocabulary tokens for document processing | |
US11636162B2 (en) | Multi-database document search system architecture | |
CN103593345A (en) | Webpage flow chart editing method and system | |
US8327261B2 (en) | Multilingual tagging of content with conditional display of unilingual tags | |
CN105354671A (en) | Universal configuration management system and enterprise-level information system comprising same | |
CN116450246A (en) | Event stream configurable method based on state machine | |
CN111221610A (en) | Page element acquisition method and device | |
Singh et al. | Generative AI Enabled Conversational Chatbot for Drilling and Production Analytics | |
Shahzad et al. | Intermingling evolutionary and versioning approach for data warehouse by Versioning-Algebra | |
Rey-Bakaikoa et al. | Managing the ADS Citation Database |
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 |