CN107179990B - Method and device for realizing test verification - Google Patents

Method and device for realizing test verification Download PDF

Info

Publication number
CN107179990B
CN107179990B CN201710347766.0A CN201710347766A CN107179990B CN 107179990 B CN107179990 B CN 107179990B CN 201710347766 A CN201710347766 A CN 201710347766A CN 107179990 B CN107179990 B CN 107179990B
Authority
CN
China
Prior art keywords
class
dialog box
programming interface
application programming
page class
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
CN201710347766.0A
Other languages
Chinese (zh)
Other versions
CN107179990A (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.)
Inspur Cloud Information Technology Co Ltd
Original Assignee
Inspur Cloud Information Technology 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 Inspur Cloud Information Technology Co Ltd filed Critical Inspur Cloud Information Technology Co Ltd
Priority to CN201710347766.0A priority Critical patent/CN107179990B/en
Publication of CN107179990A publication Critical patent/CN107179990A/en
Application granted granted Critical
Publication of CN107179990B publication Critical patent/CN107179990B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable

Abstract

A method and device for realizing test verification comprises the following steps: creating a base page class as a parent class for forms and dialogs; inheriting the form and the dialog box through the created basic page class, and packaging to obtain an application programming interface; testing and checking according to the packaged application programming interface; wherein the base page class is encapsulated with the search element and the click. The embodiment of the invention realizes the packaging of the application programming interface, avoids repeated coding during test and verification and improves the efficiency of test and verification.

Description

Method and device for realizing test verification
Technical Field
The present disclosure relates to, but not limited to, the field of testing, and more particularly, to a method and apparatus for performing test verification.
Background
In the process of carrying out automatic testing, different testing interfaces are often required to be edited for each service, programmers are required to edit different codes for each service, and a large amount of repeated work exists in the process of editing the codes, so that the testing efficiency is influenced.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the invention provides a method and a device for realizing test verification, which can reduce the codes in the test verification process and improve the test verification efficiency.
The embodiment of the invention provides a test and verification method, which comprises the following steps:
creating a base page class as a parent class for forms and dialogs;
inheriting the form and the dialog box by taking the created basic page class as a parent class, and packaging to obtain an application programming interface;
testing and checking according to the packaged application programming interface;
and the basic page class is packaged with search elements and clicks.
Optionally, the attributes included in the table include: a table toolbar and a table row;
the table includes: find element by name and click specify name element.
Optionally, the attributes included in the form toolbar include: drop down lists, input boxes, and button attributes;
the table row list type, each table row containing a table column attribute.
Optionally, the dialog box includes attributes including: drop down lists, input boxes, text areas.
Alternatively, elements of the form and dialog box use python descriptors.
On the other hand, the embodiment of the invention also provides equipment for realizing test verification, which comprises a processor, a memory and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute an image display program stored in the memory to implement the steps of:
creating a base page class as a parent class for forms and dialogs;
inheriting the form and the dialog box by taking the created basic page class as a parent class, and packaging to obtain an application programming interface;
testing and checking according to the packaged application programming interface;
and the basic page class is packaged with search elements and clicks.
Optionally, the attributes included in the table include: a table toolbar and a table row;
the table includes: looking up and clicking on the specified name element by name;
optionally, the dialog box includes attributes including: drop down lists, input boxes, text areas.
Alternatively, elements of the form and dialog box use python descriptors.
In yet another aspect, the present invention further provides a computer-readable storage medium, which stores one or more programs, where the one or more programs are executable by one or more processors to implement the steps of the method for test verification described above.
Compared with the related art, the technical scheme of the application comprises the following steps: creating a base page class as a parent class for forms and dialogs; inheriting the form and the dialog box through the created basic page class, and packaging to obtain an application programming interface; testing and checking according to the packaged application programming interface; wherein the base page class is encapsulated with the search element and the click. The embodiment of the invention realizes the packaging of the application programming interface, avoids repeated coding during test and verification and improves the efficiency of test and verification.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and not to limit the invention.
FIG. 1 is a flow chart of a method for implementing test verification according to an embodiment of the present invention;
fig. 2 is a block diagram of a device for implementing test verification according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Fig. 1 is a flowchart of a method for implementing test verification according to an embodiment of the present invention, as shown in fig. 1, including:
step 100, creating a basic page (BasePage) class as a parent class of a Table (Table) and a dialog box (Modal);
it should be noted that, the basic page class created by the embodiment of the present invention is mainly used to obtain a driver object of a Selenium (browser automation test framework, a tool for Web application test).
Optionally, the attributes included in the table in the embodiment of the present invention include: a table toolbar (top) and a table row (rows); the table includes: find by name (name _ search) and click on the named name element (name _ click);
it should be noted that, in the embodiment of the present invention, name _ search is a query filter of a table search box, and name _ click is a list click operation of each row.
Optionally, the attributes included in the table toolbar (top) in the embodiment of the present invention include: drop down list (selects), input box (input), and button (btns) attributes;
the table rows (rows) are of the list (list) type, each of which contains a table column (cols) attribute.
It should be noted that the table toolbar (top) of the embodiment of the present invention includes attributes for obtaining the operation elements above the table. The table rows may represent table elements, e.g., rows [0]. cols [1] are the table elements of the first row and the second column.
Optionally, the attributes included in the dialog box in the embodiment of the present invention include: drop down lists (selects), input boxes (input), text areas (textareas).
It should be noted that the dialog box of the embodiment of the present invention includes attributes that are elements operable in the dialog box; the method comprises the following steps (next), submission (submit), submission and check (submit _ check).
Alternatively, elements of forms and dialogs of embodiments of the present invention use python descriptors.
It should be noted that python is an object-oriented interpreted computer programming language, invented by Guido van Rossum, netherlands in 1989, and published by the first open release in 1991. Python is purely free software. The Python syntax is compact and clear, one of the features is to force whitespace (white space) as a statement indentation. Python has rich and powerful libraries. It is often nicked as a glue language and can easily join various modules made in other languages together. One common application scenario is to use Python to quickly generate a prototype of a program (sometimes even the final interface of the program), and then rewrite the specifically required parts of the program with a more appropriate language, such as a graphics rendering module in a 3D game, which has a high performance requirement, and then rewrite the program with C/C + +, and then package the program into an extended class library that Python can call. It should be noted that platform issues may need to be considered when you use the extended class library, and some may not provide for cross-platform implementations.
101, inheriting a Table (Table) and a dialog box (Modal) through the created base page class, and packaging to obtain an application programming interface;
102, testing and checking according to a packaged application programming interface;
wherein the base page class is encapsulated with a find element (find _ element) and a click (click).
It should be noted that, in the embodiment of the present invention, a find element (find _ element) and a click (click) method of a base page class package can enable inherited Table (Table) and dialog box (Modal) instances to implement find and click elements in Table and Modal.
Elements of the form and the dialog box in the embodiment of the invention use the python descriptor, and carry out unified treatment on the setting (set) and obtaining (get) methods, thereby simplifying the operation; for example, table, top, input, and 'test' are used, that is, a table search box inputs a test character, and a complicated calling method is not needed, so that the method is simple and clear.
The present invention is a world wide WEB (WEB) automation testing framework that provides an Application Programming Interface (API) to simplify the code work of testers by the Selenium-based editing of mainstream WEB application forms and dialog boxes. The Selenium is a complete set of Web application test system, which includes recording (Selenium IDE), writing and running (Selenium Remote Control) of tests and parallel processing (Selenium Grid) of tests. The core of the Selenium is written entirely in JavaScript and can therefore run on any JavaScript-enabled browser. The core of the Selenium is driven by an HTML file in a specified format, which enhances the readability of the Test Suite (Test Suite) to some extent. The Selenium Remote Control allows testers to write test code using common languages (naturally including C #, et al. NET languages) and supports a variety of mainstream browsers under different operating systems. The API provided by Selenium mainly uses webdriver, select and webelement modules. The main operation of WEB applications analyzed by the applicant is focused on tables and dialogs, wherein the tables are currently popular as data tables, and the dialogs are currently popular as Modal. The embodiment of the invention provides a simple and easy-to-use testing method for mainstream web application, unnecessary code repeated work is saved, a set of uniform interface calling of each business operation can be provided, and code personnel are not required to write different codes for each operation.
Fig. 2 is a block diagram of a device for implementing test verification according to an embodiment of the present invention, and as shown in fig. 2, the device includes a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the image display program stored in the memory to realize the following steps:
creating a basic page (BasePage) class as a parent class of tables (tables) and dialogs (Modal);
it should be noted that, the basic page class created by the embodiment of the present invention is mainly used to obtain a driver object of a Selenium (browser automation test framework, a tool for Web application test).
Inheriting a Table (Table) and a dialog box (Modal) through the created base page class, and packaging to obtain an application programming interface;
testing and checking according to the packaged application programming interface;
wherein the base page class is encapsulated with a find element (find _ element) and a click (click).
It should be noted that, in the embodiment of the present invention, a find element (find _ element) and a click (click) method of a base page class package can enable inherited Table (Table) and dialog box (Modal) instances to implement find and click elements in Table and Modal.
Optionally, the attributes included in the table include: a table toolbar (top) and a table row (rows);
the table includes: find by name (name _ search) and click on the named name element (name _ click);
it should be noted that, in the embodiment of the present invention, name _ search is a query filter of a table search box, and name _ click is a list click operation of each row.
Optionally, the attributes included in the table toolbar (top) in the embodiment of the present invention include: drop down list (selects), input box (input), and button (btns) attributes;
the table rows (rows) are of the list (list) type, each of which contains a table column (cols) attribute.
It should be noted that the table toolbar (top) of the embodiment of the present invention includes attributes for obtaining the operation elements above the table. The table rows may represent table elements, e.g., rows [0]. cols [1] are the table elements of the first row and the second column.
Optionally, the dialog box includes attributes including: drop down lists (selects), input boxes (input), text areas (textareas).
It should be noted that the dialog box of the embodiment of the present invention includes attributes that are elements operable in the dialog box; the method comprises the following steps (next), submission (submit), submission and check (submit _ check).
Alternatively, elements of the form and dialog box use python descriptors.
Elements of the form and the dialog box in the embodiment of the invention use the python descriptor, and carry out unified treatment on the setting (set) and obtaining (get) methods, thereby simplifying the operation; for example, table, top, input, and 'test' are used, that is, a table search box inputs a test character, and a complicated calling method is not needed, so that the method is simple and clear.
In still another aspect, an embodiment of the present invention is a computer-readable storage medium, where one or more programs are stored, and the one or more programs are executable by one or more processors to implement the method for test verification described above.
The method of the embodiment of the present invention is described in detail below by using application examples, which are only used for illustrating the present invention and are not used for limiting the protection scope of the present invention.
Application example
The embodiment of the invention firstly creates a basic page (BasePage) class as a parent class of a Table (Table) and a dialog box (Modal), mainly aims to acquire a driver (driver) object of a Selenium, and encapsulates a search element (find _ element) and a click method, wherein the encapsulated search element and click method can ensure that the inherited Table and Modal are search and click elements in the Table and Modal. Example codes are as follows:
Figure GDA0002383623520000071
the method mainly comprises two attributes of a Table toolbar (top) and a Table row (rows), a name search (name _ search) method and a name element click (name _ click) method, wherein the top attribute comprises a pull-down list (selections), an input box (input) and a button (btns) attribute and is used for obtaining operation elements above the Table, the rows are of a list (list) type, and each row comprises a Table column (cols) attribute, for example, the rows [0] and the cols [1] are Table elements of a first row and a second column; name _ search is the query filter for the table search box, and name _ click is the list click operation for each row. Example codes are as follows:
Figure GDA0002383623520000081
Figure GDA0002383623520000091
in the embodiment of the present invention, Modal is also a subclass of BasePage, and its attributes mainly include selections, inputs, and text areas (textareas), which are elements operable in a dialog box, including next, submit, and submit _ check, respectively, for next step, submission, and submission and verification. Example codes are as follows:
Figure GDA0002383623520000101
Figure GDA0002383623520000111
Figure GDA0002383623520000121
in the embodiment of the invention, the elements of the form and the dialog box use the python descriptor to carry out unified processing on the set and get methods, so that the operation is simplified, for example, table. Example codes are as follows:
Figure GDA0002383623520000122
the creating logic of a service of the application example can complete testing and checking through the following simple codes, and is uniformly applicable to each service, so that the distinguishing operation on the codes is not required to be performed each time:
def test_01_add(self):
self.table.top.btns['btn-add'].click()
self.modal.inputs['name']='selenium'
self.modal.inputs['code']='selenium'
self.modal.inputs['value']='selenium'
self.modal.inputs['order_num']='1'
assert self.modal.submit_check()
the application example provides a set of simple and easy-to-use testing method for main web application, unnecessary code repeated work is saved, a set of uniform interface calling of each business operation can be provided, and code personnel are not required to write different codes for each operation.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by a program instructing associated hardware (e.g., a processor) to perform the steps, and the program may be stored in a computer readable storage medium, such as a read only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the above embodiments may be implemented using one or more integrated circuits. Accordingly, each module/unit in the above embodiments may be implemented in hardware, for example, by an integrated circuit to implement its corresponding function, or in software, for example, by a processor executing a program/instruction stored in a memory to implement its corresponding function. The present invention is not limited to any specific form of combination of hardware and software.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A method of test verification, comprising:
creating a base page class as a parent class for forms and dialogs;
inheriting the form and the dialog box by taking the created basic page class as a parent class, and packaging to obtain an application programming interface;
testing and checking according to the packaged application programming interface;
and the basic page class is packaged with search elements and clicks.
2. The method of claim 1,
the table contains attributes including: a table toolbar and a table row;
the table includes: find element by name and click specify name element.
3. The method of claim 2, wherein the form toolbar contains attributes comprising: drop down lists, input boxes, and button attributes;
the table row list type, each table row containing a table column attribute.
4. The method of claim 1, wherein the dialog box contains attributes comprising: drop down lists, input boxes, text areas.
5. A method according to any of claims 1 to 4, wherein elements of the forms and dialogs use python descriptors.
6. An apparatus for implementing test verification, the apparatus comprising a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute an image display program stored in the memory to implement the steps of:
creating a base page class as a parent class for forms and dialogs;
inheriting the form and the dialog box by taking the created basic page class as a parent class, and packaging to obtain an application programming interface;
testing and checking according to the packaged application programming interface;
and the basic page class is packaged with search elements and clicks.
7. The apparatus of claim 6, wherein the table contains attributes comprising: a table toolbar and a table row;
the table includes: the name element is specified by name lookup and clicking.
8. The apparatus of claim 6, wherein the dialog box contains attributes comprising: drop down lists, input boxes, text areas.
9. An apparatus as claimed in any one of claims 6 to 8, wherein elements of the forms and dialogs use python descriptors.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores one or more programs executable by one or more processors to implement the steps of the method of test validation as claimed in claims 1-5.
CN201710347766.0A 2017-05-17 2017-05-17 Method and device for realizing test verification Active CN107179990B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710347766.0A CN107179990B (en) 2017-05-17 2017-05-17 Method and device for realizing test verification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710347766.0A CN107179990B (en) 2017-05-17 2017-05-17 Method and device for realizing test verification

Publications (2)

Publication Number Publication Date
CN107179990A CN107179990A (en) 2017-09-19
CN107179990B true CN107179990B (en) 2020-09-08

Family

ID=59831548

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710347766.0A Active CN107179990B (en) 2017-05-17 2017-05-17 Method and device for realizing test verification

Country Status (1)

Country Link
CN (1) CN107179990B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10320207A (en) * 1997-05-01 1998-12-04 Internatl Business Mach Corp <Ibm> System and method for developing object oriented application
CN101297268A (en) * 2005-03-03 2008-10-29 汤姆森环球资源公司 Integrated system, tools, and methods for designing automated business process applications
CN101315604A (en) * 2008-06-30 2008-12-03 华为技术有限公司 Method and system for implementing software customized module
CN102169637A (en) * 2010-12-08 2011-08-31 北京大学 Dynamic route guidance method oriented to urban traffic
CN102495734A (en) * 2011-12-12 2012-06-13 方正国际软件有限公司 Inheritable toolbar system and achieving method thereof
CN105260318A (en) * 2015-11-25 2016-01-20 飞天诚信科技股份有限公司 Automatic testing method and device based on web pages

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7086067B1 (en) * 2000-07-14 2006-08-01 International Business Machines Corporation Dynamic Java bean for VisualAge for Java
US8375356B2 (en) * 2008-06-16 2013-02-12 Microsoft Corporation Tabular completion lists

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10320207A (en) * 1997-05-01 1998-12-04 Internatl Business Mach Corp <Ibm> System and method for developing object oriented application
CN101297268A (en) * 2005-03-03 2008-10-29 汤姆森环球资源公司 Integrated system, tools, and methods for designing automated business process applications
CN101315604A (en) * 2008-06-30 2008-12-03 华为技术有限公司 Method and system for implementing software customized module
CN102169637A (en) * 2010-12-08 2011-08-31 北京大学 Dynamic route guidance method oriented to urban traffic
CN102495734A (en) * 2011-12-12 2012-06-13 方正国际软件有限公司 Inheritable toolbar system and achieving method thereof
CN105260318A (en) * 2015-11-25 2016-01-20 飞天诚信科技股份有限公司 Automatic testing method and device based on web pages

Also Published As

Publication number Publication date
CN107179990A (en) 2017-09-19

Similar Documents

Publication Publication Date Title
US11561887B2 (en) Test script debugging using an automated testing framework and UI rendering tree
CN107291438B (en) Automatic script generation method and device and electronic equipment
CN110489116B (en) Page rendering method and device and computer storage medium
CN107644286B (en) Workflow processing method and device
CN110134386B (en) Program editing method and device
US9690549B2 (en) Editing software products using text mapping files
CN106933887B (en) Data visualization method and device
CN106354483B (en) Data processing method and device and electronic equipment
CN107066377B (en) Page element obtaining method based on Android system and terminal equipment
CN112083920A (en) Front-end page design method, device, storage medium and equipment
CN112765023A (en) Test case generation method and device
US20150317405A1 (en) Web Page Variation
CN102693238B (en) Widget application process, system and multimedia terminal
CN107015903B (en) Interface test program generation method and device and electronic equipment
US9384300B2 (en) Modeled applications multiple views generation mechanism
CN109902003B (en) Test script generation method and device
US20120072823A1 (en) Natural language assertion
CN114328250A (en) Automatic self-checking method, medium and device for software system
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN107179990B (en) Method and device for realizing test verification
CN113641594B (en) Cross-terminal automatic testing method and related device
US20160292067A1 (en) System and method for keyword based testing of custom components
US11474927B1 (en) Verification of control coupling and data coupling analysis in software code
CN111061522A (en) Method, device, equipment and storage medium for generating front-end card assembly based on back end
CN114077430A (en) Interface generation method and device, electronic 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
TA01 Transfer of patent application right

Effective date of registration: 20200522

Address after: 250101 floor 27, S01, Inspur Science Park, No. 1036, Inspur Road, Jinan City, Shandong Province

Applicant after: Tidal Cloud Information Technology Co.,Ltd.

Address before: 450018 Henan province Zheng Dong New District of Zhengzhou City Xinyi Road No. 278 16 floor room 1601

Applicant before: ZHENGZHOU YUNHAI INFORMATION TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
CB02 Change of applicant information

Address after: 250101 floor 27, S01, Inspur Science Park, No. 1036, Inspur Road, Jinan City, Shandong Province

Applicant after: Inspur cloud Information Technology Co., Ltd

Address before: 250101 floor 27, S01, Inspur Science Park, No. 1036, Inspur Road, Jinan City, Shandong Province

Applicant before: Tidal Cloud Information Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant