CN111737152B - Method and device for realizing WEB automated testing through web page entry data - Google Patents
Method and device for realizing WEB automated testing through web page entry data Download PDFInfo
- Publication number
- CN111737152B CN111737152B CN202010740552.1A CN202010740552A CN111737152B CN 111737152 B CN111737152 B CN 111737152B CN 202010740552 A CN202010740552 A CN 202010740552A CN 111737152 B CN111737152 B CN 111737152B
- Authority
- CN
- China
- Prior art keywords
- data
- verification
- test
- tested
- selenium
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
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
本发明提供一种通过网页录入数据实现WEB自动化测试的方法及装置,所述方法包括:在服务器中配置selenium框架及执行器;通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端;通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验;通过图形接口页面查看校验结果。根据本发明的方案,将用户的输入转义成自动化框架的函数和输入参数,实现了通过web录入的方式实现传统通过编码方式实现的软件测试自动化。
The invention provides a method and a device for realizing WEB automated testing through web page input data. The method includes: configuring a selenium framework and an executor in a server; The data includes control data, element data, and verification data, and the key data is stored in the database; the execution command is sent through the graphical interface, and the executor in the server calls the selenium framework to drive the web page to be tested to load the key data for execution. Automate the test and use the loaded verification data for verification; view the verification results through the graphical interface page. According to the solution of the present invention, the user's input is escaped into the functions and input parameters of the automation framework, thereby realizing the automation of software testing traditionally realized by coding by means of web input.
Description
技术领域technical field
本发明涉及软件测试自动化技术领域,尤其涉及一种通过网页录入数据实现WEB自动化测试的方法及装置。The invention relates to the technical field of software testing automation, in particular to a method and device for realizing WEB automatic testing through web page input data.
背景技术Background technique
随着现代社会信息化的不断发展,为了满足人们工作生活需要,各种软件产品井喷式出现。同时,为满足不同的差异化个性化需求,软件也变的越来越复杂。为了应对越来越多,越来越复杂的软件应用,保证软件的可靠性,大量的软件测试人员付出了辛勤的劳动。在软件测试过程中存在大量的、重复的劳动,在此背景下各种通过编程方式实现的自动化软件测试技术应运而生。自动化测试的实现要求项目组中的软件测试人员使用同一种编程语言对各自测试软件的模块的测试工作通过自动执行的代码方式实现,以代替手工页面操作。测试人员实现自动化代码后,可以在多次反复执行,以实现避免重复劳动的效果。With the continuous development of informatization in modern society, in order to meet the needs of people's work and life, a variety of software products have emerged. At the same time, in order to meet different differentiated and personalized needs, the software has become more and more complex. In order to deal with more and more and more complex software applications and ensure the reliability of the software, a large number of software testers have worked hard. In the process of software testing, there is a lot of repetitive work, and in this context, various automatic software testing technologies realized by programming emerge as the times require. The realization of automated testing requires software testers in the project team to use the same programming language to test the modules of their respective testing software through automatic code execution instead of manual page operations. After the tester realizes the automated code, it can be repeatedly executed many times to achieve the effect of avoiding duplication of work.
WEB软件测试自动化解决了部分软件测试过程中重复劳动的弊端,但也存在以下一些问题:1.自动化需要测试人员掌握编程能力,但是目前测试从业人员中能够编程的比例不高。2.为了方便自动化测试用例代码的管理,项目中一般要求自动化用例使用同一种编程语言编写,对测试小组编程素质是一种更严苛的要求。3.自动化用例以代码方式存在,不同测试人员的代码风格可能大相径庭,不方便用例的审查。4.用例存储在测试人员本地,不方便合作开发,不方便测试人员间用例的复用。WEB software testing automation solves the drawbacks of repetitive labor in some software testing processes, but there are also some problems as follows: 1. Automation requires testers to master programming skills, but at present, the proportion of testing practitioners who can program is not high. 2. In order to facilitate the management of the automated test case code, the automated test case is generally required to be written in the same programming language in the project, which is a more stringent requirement for the programming quality of the test team. 3. Automated use cases exist in the form of code, and the code styles of different testers may be very different, which is inconvenient to review use cases. 4. Use cases are stored locally by testers, which is inconvenient for collaborative development and reuse of use cases among testers.
发明内容SUMMARY OF THE INVENTION
为解决上述技术问题,本发明提出了一种通过网页录入数据实现WEB自动化测试的方法及装置,所述方法及装置,用以解决现有技术中自动化需要测试人员掌握编程能力,但是目前测试从业人员中能够编程的比例不高;自动化用例以代码方式存在,不同测试人员的代码风格可能大相径庭,不方便用例的审查;用例存储在测试人员本地,不方便合作开发,不方便测试人员间用例的复用的技术问题。In order to solve the above-mentioned technical problems, the present invention proposes a method and device for realizing WEB automated testing through web page entry data. The proportion of personnel who can program is not high; automation use cases exist in the form of code, and the code styles of different testers may be very different, which is inconvenient for use case review; use cases are stored locally by testers, which is not convenient for collaborative development and is not convenient for testers. Technical issues of reuse.
根据本发明的第一方面,提供一种通过网页录入数据实现WEB自动化测试的方法,所述方法包括以下步骤:According to a first aspect of the present invention, there is provided a method for implementing WEB automated testing by entering data on a web page, the method comprising the following steps:
步骤S101:在服务器中配置selenium框架及执行器,所述执行器内部存储三张映射表,分别是页面控制器映射表、元素定位器映射表、元素控制器映射表,用于将数据库中存储的用例数据映射为由selenium框架调用的函数及与函数对应的参数;Step S101: Configure the selenium framework and the executor in the server, and the executor internally stores three mapping tables, which are the page controller mapping table, the element locator mapping table, and the element controller mapping table, which are used to store in the database. The use case data is mapped to the function called by the selenium framework and the parameters corresponding to the function;
步骤S102:通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端;所述图形接口与待测web网页配置在不同的终端上;Step S102: Input the key data of each test step of the automated test case through the graphical interface, the key data includes control data, element data, and verification data, and store the key data in the database; The web pages are configured on different terminals;
步骤S103:通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验;Step S103: sending an execution command through the graphical interface, the executor in the server calls the selenium framework to drive the web page to be tested to load the key data to perform automated testing, and uses the loaded verification data for verification;
步骤S104:通过图形接口页面查看校验结果。Step S104: View the verification result through the graphical interface page.
进一步地,所述步骤S102:通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端,包括:Further, the step S102: input the key data of each test step of the automated test case through the graphical interface, the key data includes control data, element data, and verification data, and store the key data in the database, including:
将测试用例划分为若干个测试步骤,通过图形接口录入每个测试步骤需要的控制数据、元素数据、校验数据,所述图形接口为HTML网页,通过HTTP协议将所述控制数据、元素数据、校验数据存储于数据库中;所述控制数据包括待测web页面的操作行为、操作值,所述元素数据包括待测web页面中待测对象的定位方式、定位字符串,所述校验数据包括校验方式、校验值,待测web页面中待测对象按操作行为、及操作值操作后,通过校验数据进行验证。The test case is divided into several test steps, and the control data, element data, and verification data required for each test step are entered through a graphical interface. The graphical interface is an HTML web page, and the control data, element data, The verification data is stored in the database; the control data includes the operation behavior and operation value of the web page to be tested, the element data includes the positioning method and the positioning string of the object to be tested in the web page to be tested, and the verification data Including the verification method and verification value, after the object to be tested in the web page to be tested is operated according to the operation behavior and operation value, it is verified by the verification data.
进一步地,所述步骤S103:通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验,包括:Further, the step S103: sending an execution command through a graphical interface, the executor in the server calls the selenium framework to drive the web page to be tested to load the key data to perform automated testing, and uses the loaded verification data for verification, including: :
步骤S1031:通过图形接口发送测试用例执行命令,服务器从数据库端获取该测试用例对应的各测试步骤的关键数据,并将所述关键数据传入执行器;执行器将第一个待执行的测试步骤作为当前测试步骤;Step S1031: Send the test case execution command through the graphical interface, the server obtains the key data of each test step corresponding to the test case from the database, and transmits the key data to the executor; the executor sends the first test to be executed step as the current test step;
步骤S1032:执行器获取当前测试步骤的操作数据、元素数据,所述操作数据包括待测web页面的操作行为、操作值;根据操作数据选择进入页面控制器或元素控制器:若操作数据中的操作行为属于页面控制器映射表,则进入页面控制器,获取操作值,查询页面控制器映射表,调用selenium中的相应函数,在selenium页面控制该相应函数中传入操作值,并执行该函数;若操作数据中的操作行为属于元素控制器映射表,则进入元素控制器,查询元素定位器映射表,调用与元素数据对应的selenium函数,并获取selenium函数返回的元素实例,再查询元素控制器映射表,调用selenium相应的元素控制函数,传入元素实例和操作值并执行;Step S1032: The executor obtains the operation data and element data of the current test step, and the operation data includes the operation behavior and operation value of the web page to be tested; according to the operation data, select the entry page controller or the element controller: if the operation data is If the operation behavior belongs to the page controller mapping table, enter the page controller, obtain the operation value, query the page controller mapping table, call the corresponding function in selenium, pass in the operation value in the corresponding function of the selenium page control, and execute the function ;If the operation behavior in the operation data belongs to the element controller mapping table, enter the element controller, query the element locator mapping table, call the selenium function corresponding to the element data, and obtain the element instance returned by the selenium function, and then query the element control The device mapping table, call the corresponding element control function of selenium, pass in the element instance and operation value and execute it;
步骤S1033:执行器获取当前测试步骤的校验数据,调用selenium函数从待测web网页获取运行该测试步骤的实际运行值,将校验数据与实际运行值传入校验器进行验证,输出验证结果并将验证结果存入数据库端;Step S1033: The executor obtains the verification data of the current test step, calls the selenium function to obtain the actual running value of the test step from the web page to be tested, transfers the verification data and the actual running value to the verifier for verification, and outputs the verification The result and the verification result is stored in the database side;
步骤S1034:判断是否执行完全部测试步骤,若是,方法结束;若否,将下一个待测试步骤作为当前测试步骤,进入步骤S1032。Step S1034: Determine whether to execute all the test steps, if yes, the method ends; if not, take the next step to be tested as the current test step, and go to step S1032.
进一步地,在步骤S104之后,根据校验结果,通过图形接口对web网页的测试用例进行修改、复制。Further, after step S104, according to the verification result, the test case of the web page is modified and copied through the graphical interface.
根据本发明第二方面,提供一种通过selenium网页录入数据实现WEB自动化测试的装置,所述装置包括:According to a second aspect of the present invention, there is provided a device for implementing WEB automated testing by entering data on a selenium web page, the device comprising:
配置模块:在服务器中配置selenium框架及执行器,所述执行器内部存储三张映射表,分别是页面控制器映射表、元素定位器映射表、元素控制器映射表,用于将数据库中存储的用例数据映射为由selenium框架调用的函数及与函数对应的参数;Configuration module: Configure the selenium framework and the executor in the server. The executor stores three mapping tables inside, which are the page controller mapping table, the element locator mapping table, and the element controller mapping table, which are used to store in the database. The use case data is mapped to the function called by the selenium framework and the parameters corresponding to the function;
录入模块:通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端;所述图形接口与待测web网页配置在不同的终端上;Input module: input the key data of each test step of the automated test case through the graphical interface, the key data includes control data, element data, verification data, and store the key data in the database; The web pages are configured on different terminals;
测试模块:通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验;Test module: send an execution command through a graphical interface, the executor in the server calls the selenium framework to drive the web page to be tested to load the key data to perform automated testing, and use the loaded verification data for verification;
查看结果模块:通过图形接口页面查看校验结果。View Results Module: View calibration results through the graphical interface page.
进一步地,所述录入模块,包括:Further, the input module includes:
录入子模块,用于将测试用例划分为若干个测试步骤,通过图形接口录入每个测试步骤需要的控制数据、元素数据、校验数据,所述图形接口为HTML网页,通过HTTP协议将所述控制数据、元素数据、校验数据存储于数据库中;所述控制数据包括待测web页面的操作行为、操作值,所述元素数据包括待测web页面中待测对象的定位方式、定位字符串,所述校验数据包括校验方式、校验值,待测web页面中待测对象按操作行为、及操作值操作后,通过校验数据进行验证。The input sub-module is used to divide the test case into several test steps, and input the control data, element data, and verification data required by each test step through a graphical interface. The control data, element data, and verification data are stored in the database; the control data includes the operation behavior and operation value of the web page to be tested, and the element data includes the positioning method and the positioning string of the object to be tested in the web page to be tested. The verification data includes a verification method and a verification value. After the object to be tested in the web page to be tested operates according to the operation behavior and the operation value, the verification data is used for verification.
进一步地,所述测试模块,包括:Further, the test module includes:
测试命令生成子模块:通过图形接口发送测试用例执行命令,服务器从数据库端获取该测试用例对应的各测试步骤的关键数据,并将所述关键数据传入执行器;执行器将第一个待执行的测试步骤作为当前测试步骤;Test command generation sub-module: send the test case execution command through the graphical interface, the server obtains the key data of each test step corresponding to the test case from the database, and transmits the key data to the executor; The executed test step is used as the current test step;
测试子模块:执行器获取当前测试步骤的操作数据、元素数据,所述操作数据包括待测web页面的操作行为、操作值;根据操作数据选择进入页面控制器或元素控制器:若操作数据中的操作行为属于页面控制器映射表,则进入页面控制器,获取操作值,查询页面控制器映射表,调用selenium中的相应函数,在selenium页面控制该相应函数中传入操作值,并执行该函数;若操作数据中的操作行为属于元素控制器映射表,则进入元素控制器,查询元素定位器映射表,调用与元素数据对应的selenium函数,并获取selenium函数返回的元素实例,再查询元素控制器映射表,调用selenium相应的元素控制函数,传入元素实例和操作值并执行;Test sub-module: the executor obtains the operation data and element data of the current test step, and the operation data includes the operation behavior and operation value of the web page to be tested; according to the operation data, the page controller or the element controller is selected; if the operation data is in the The operation behavior belongs to the page controller mapping table, then enter the page controller, obtain the operation value, query the page controller mapping table, call the corresponding function in selenium, pass in the operation value in the corresponding function of the selenium page control, and execute the Function; if the operation behavior in the operation data belongs to the element controller mapping table, enter the element controller, query the element locator mapping table, call the selenium function corresponding to the element data, obtain the element instance returned by the selenium function, and then query the element Controller mapping table, call the corresponding element control function of selenium, pass in the element instance and operation value and execute it;
校验子模块:执行器获取当前测试步骤的校验数据,调用selenium函数从待测web网页获取运行该测试步骤的实际运行值,将校验数据与实际运行值传入校验器进行验证,输出验证结果并将验证结果存入数据库端;Verification sub-module: The executor obtains the verification data of the current test step, calls the selenium function to obtain the actual running value of the test step from the web page to be tested, and transmits the verification data and the actual running value to the validator for verification. Output the verification result and store the verification result in the database;
判断子模块:判断是否执行完全部测试步骤。Judging sub-module: Judging whether to execute all test steps.
进一步地,所述过网页录入数据实现WEB自动化测试的装置,包括修改及复制子模块,用于根据校验结果,通过图形接口对web网页的测试用例进行修改、复制。Further, the device for implementing automatic WEB testing by entering data through a web page includes a modification and duplication sub-module for modifying and duplicating the test case of the web page through a graphical interface according to the verification result.
根据本发明第三方面,提供一种通过网页录入数据实现WEB自动化测试的系统,包括:According to a third aspect of the present invention, there is provided a system for implementing WEB automated testing through web page entry data, including:
处理器,用于执行多条指令;a processor for executing multiple instructions;
存储器,用于存储多条指令;memory for storing multiple instructions;
其中,所述多条指令,用于由所述存储器存储,并由所述处理器加载并执行如前所述的通过网页录入数据实现WEB自动化测试的方法。Wherein, the plurality of instructions are used to be stored by the memory, and loaded by the processor to execute the method for implementing WEB automated testing by entering data through a web page as described above.
根据本发明第四方面,提供一种计算机可读存储介质,所述存储介质中存储有多条指令;所述多条指令,用于由处理器加载并执行如前所述的通过网页录入数据实现WEB自动化测试的方法。According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein a plurality of instructions are stored in the storage medium; the plurality of instructions are used by a processor to load and execute the aforementioned data entry through a web page How to implement web automation testing.
根据本发明的上述方案,通过向用户提供web页面接口,将用户的输入转义成自动化框架的函数和输入参数,实现了通过web录入的方式实现传统通过编码方式实现的软件测试自动化,无需编码,大大降低了自动化测试用例的开发门槛,将自动化测试用例开发的编码过程简化为页面数据录入过程,将用例的每一步都数据化,并使原本耦合在代码中的内容解耦成一条条参数化的数据存储在数据仓库中,方便引用、用例的拷贝和批量复制,极大地提高了开发效率。将自动化测试的用例划分为一个个执行步骤,方便错误排查及定位。使得用例平台化,可以快速开发、审查用例。According to the above solution of the present invention, by providing the user with a web page interface, the user's input is escaped into the functions and input parameters of the automation framework, so as to realize the automation of software testing by means of web entry, which is traditionally realized by coding, without coding. , which greatly reduces the development threshold of automated test cases, simplifies the coding process of automated test case development into the page data entry process, digitizes every step of the use case, and decouples the content originally coupled in the code into parameters. The data is stored in the data warehouse, which is convenient for reference, use case copying and batch replication, which greatly improves the development efficiency. Divide the use cases of automated testing into execution steps to facilitate error troubleshooting and positioning. The use case is platformized, and the use case can be developed and reviewed quickly.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,并可依照说明书的内容予以实施,以下以本发明的较佳实施例并配合附图详细说明如后。The above description is only an overview of the technical solution of the present invention. In order to understand the technical means of the present invention more clearly, and implement it according to the content of the description, the preferred embodiments of the present invention are described in detail below with the accompanying drawings.
附图说明Description of drawings
构成本发明的一部分的附图用来提供对本发明的进一步理解,本发明提供如下附图进行说明。在附图中:The accompanying drawings, which form a part of this disclosure, are provided to provide a further understanding of the present disclosure, and the present disclosure is provided with the following figures to illustrate. In the attached image:
图1为本发明一个实施方式的通过网页录入数据实现WEB自动化测试的方法流程图;1 is a flowchart of a method for implementing WEB automated testing by entering data on a webpage according to an embodiment of the present invention;
图2为本发明一个实施方式的实现WEB自动化测试的系统架构图;FIG. 2 is a system architecture diagram for realizing WEB automated testing according to an embodiment of the present invention;
图3为本发明一个实施方式的部件关联图;FIG. 3 is a component association diagram of an embodiment of the present invention;
图4为本发明一个实施方式的录入操作信息示意图;4 is a schematic diagram of input operation information according to an embodiment of the present invention;
图5为本发明一个实施方式的录入元素信息示意图;5 is a schematic diagram of input element information according to an embodiment of the present invention;
图6为本发明一个实施方式的录入校验信息示意图;6 is a schematic diagram of input verification information according to an embodiment of the present invention;
图7为本发明一个实施方式的页面控制器映射表示意图;7 is a schematic diagram of a page controller mapping table according to an embodiment of the present invention;
图8为本发明一个实施方式的元素定位器映射表示意图;8 is a schematic diagram of an element locator mapping table according to an embodiment of the present invention;
图9为本发明一个实施方式的元素控制器映射表示意图;9 is a schematic diagram of an element controller mapping table according to an embodiment of the present invention;
图10为本发明一个实施方式的通过网页录入数据实现WEB自动化测试的装置结构框图。FIG. 10 is a structural block diagram of an apparatus for implementing WEB automated testing by entering data on a webpage according to an embodiment of the present invention.
附图标记说明:Description of reference numbers:
1:用户图形接口;2:系统服务器;3:数据库服务器。1: User graphical interface; 2: System server; 3: Database server.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚,下面将结合本发明具体实施例及相应的附图对本发明技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only some, but not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
首先结合图1说明为本发明一个实施方式的实现WEB自动化测试的方法流程图,图2示出了本实施例的一个实施方式的实现WEB自动化测试的系统架构图。如图1-2所示,所述方法包括以下步骤:First, a flowchart of a method for implementing WEB automated testing according to an embodiment of the present invention is described with reference to FIG. 1 , and FIG. 2 shows a system architecture diagram for implementing WEB automated testing according to an embodiment of the present embodiment. As shown in Figure 1-2, the method includes the following steps:
步骤S101:在服务器中配置selenium框架及执行器,所述执行器内部存储三张映射表,分别是页面控制器映射表、元素定位器映射表、元素控制器映射表,用于将数据库中存储的用例数据映射为由selenium框架调用的函数及与函数对应的参数;Step S101: Configure the selenium framework and the executor in the server, and the executor internally stores three mapping tables, which are the page controller mapping table, the element locator mapping table, and the element controller mapping table, which are used to store in the database. The use case data is mapped to the function called by the selenium framework and the parameters corresponding to the function;
步骤S102:通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端;所述图形接口与待测web网页配置在不同的终端上;Step S102: Input the key data of each test step of the automated test case through the graphical interface, the key data includes control data, element data, and verification data, and store the key data in the database; The web pages are configured on different terminals;
步骤S103:通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验;Step S103: sending an execution command through the graphical interface, the executor in the server calls the selenium framework to drive the web page to be tested to load the key data to perform automated testing, and uses the loaded verification data for verification;
步骤S104:通过图形接口页面查看校验结果。Step S104: View the verification result through the graphical interface page.
所述步骤S102:通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端,包括:The step S102: input the key data of each test step of the automated test case through the graphical interface, the key data includes control data, element data, and verification data, and store the key data in the database, including:
将测试用例划分为若干个测试步骤,通过图形接口录入每个测试步骤需要的控制数据、元素数据、校验数据,所述图形接口为HTML网页,通过HTTP协议将所述控制数据、元素数据、校验数据存储于数据库中;所述控制数据包括待测web页面的操作行为、操作值,所述元素数据包括待测web页面中待测对象的定位方式、定位字符串,所述校验数据包括校验方式、校验值,待测web页面中待测对象按操作行为、及操作值操作后,通过校验数据进行验证。The test case is divided into several test steps, and the control data, element data, and verification data required for each test step are entered through a graphical interface. The graphical interface is an HTML web page, and the control data, element data, The verification data is stored in the database; the control data includes the operation behavior and operation value of the web page to be tested, the element data includes the positioning method and the positioning string of the object to be tested in the web page to be tested, and the verification data Including the verification method and verification value, after the object to be tested in the web page to be tested is operated according to the operation behavior and operation value, it is verified by the verification data.
所述步骤S103:通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验,包括:The step S103: sending an execution command through a graphical interface, the executor in the server calls the selenium framework to drive the web page to be tested to load the key data to perform automated testing, and uses the loaded verification data for verification, including:
步骤S1031:通过图形接口发送测试用例执行命令,服务器从数据库端获取该测试用例对应的各测试步骤的关键数据,并将所述关键数据传入执行器;执行器将第一个待执行的测试步骤作为当前测试步骤;Step S1031: Send the test case execution command through the graphical interface, the server obtains the key data of each test step corresponding to the test case from the database, and transmits the key data to the executor; the executor sends the first test to be executed step as the current test step;
步骤S1032:执行器获取当前测试步骤的操作数据、元素数据,所述操作数据包括待测web页面的操作行为、操作值;根据操作数据选择进入页面控制器或元素控制器:若操作数据中的操作行为属于页面控制器映射表,则进入页面控制器,获取操作值,查询页面控制器映射表,调用selenium中的相应函数,在selenium页面控制该相应函数中传入操作值,并执行该函数;若操作数据中的操作行为属于元素控制器映射表,则进入元素控制器,查询元素定位器映射表,调用与元素数据对应的selenium函数,并获取selenium函数返回的元素实例,再查询元素控制器映射表,调用selenium相应的元素控制函数,传入元素实例和操作值并执行;Step S1032: The executor obtains the operation data and element data of the current test step, and the operation data includes the operation behavior and operation value of the web page to be tested; according to the operation data, select the entry page controller or the element controller: if the operation data is If the operation behavior belongs to the page controller mapping table, enter the page controller, obtain the operation value, query the page controller mapping table, call the corresponding function in selenium, pass in the operation value in the corresponding function of the selenium page control, and execute the function ;If the operation behavior in the operation data belongs to the element controller mapping table, enter the element controller, query the element locator mapping table, call the selenium function corresponding to the element data, and obtain the element instance returned by the selenium function, and then query the element control The device mapping table, call the corresponding element control function of selenium, pass in the element instance and operation value and execute it;
步骤S1033:执行器获取当前测试步骤的校验数据,调用selenium函数从待测web网页获取运行该测试步骤的实际运行值,将校验数据与实际运行值传入校验器进行验证,输出验证结果并将验证结果存入数据库端;Step S1033: The executor obtains the verification data of the current test step, calls the selenium function to obtain the actual running value of the test step from the web page to be tested, transfers the verification data and the actual running value to the verifier for verification, and outputs the verification The result and the verification result is stored in the database side;
步骤S1034:判断是否执行完全部测试步骤,若是,方法结束;若否,将下一个待测试步骤作为当前测试步骤,进入步骤S1032。Step S1034: Determine whether to execute all the test steps, if yes, the method ends; if not, take the next step to be tested as the current test step, and go to step S1032.
所述服务器可以向数据库端插入、修改、请求数据,待测web网页执行自动化测试,调用用例时,由服务器的执行器解析数据,并映射出用例被执行时所需要的数据。The server can insert, modify, and request data from the database, and the web page to be tested performs automated testing. When a use case is invoked, the server's executor parses the data and maps the data required when the use case is executed.
所述数据库端用于存储通过图形接口录入的各个测试步骤所需的数据,在执行测试用例时提供给服务器;存储测试用例各个测试步骤执行的结果;还可以接受发送的调整测试用例各步骤的顺序、复制测试用例等命令,实现测试用例的灵活调整和复用。The database end is used to store the data required for each test step entered through the graphical interface, and provide it to the server when the test case is executed; store the results of each test step execution of the test case; and can also accept the sent adjustment of each step of the test case. Order, copy test cases and other commands to achieve flexible adjustment and reuse of test cases.
本实施例中用户图形接口1、服务器2、数据库3的关联关系如图3所示。In this embodiment, the association relationship among the user
进一步地,本实施例还在步骤S104:查看校验结果之后,根据校验结果,通过图形接口对web网页的测试用例进行修改、复制。Further, in this embodiment, step S104: after checking the verification result, modify and copy the test case of the web page through the graphical interface according to the verification result.
本实施例中的录入操作信息、录入元素信息、录入校验信息、页面控制器映射表、元素定位器映射表、元素控制器映射表分别参考图4-9。For the input operation information, input element information, input verification information, page controller mapping table, element locator mapping table, and element controller mapping table in this embodiment, refer to FIGS. 4-9 respectively.
又一实施例说明本发明的一个具体应用。Yet another embodiment illustrates one specific application of the present invention.
测试人员根据实际情况将一个测试场景对应的测试用例划分为若干个测试步骤,并在图形接口逐个输入每个测试步骤需要的数据。以用户登录场景为例,第一步需要在登录页面用户名输入框中输入用户名,则用户需要录入的数据如下:Testers divide the test case corresponding to a test scenario into several test steps according to the actual situation, and input the data required by each test step one by one on the graphical interface. Taking the user login scenario as an example, the first step is to enter the user name in the user name input box on the login page. The data that the user needs to enter is as follows:
操作数据包括操作方法和操作值,操作方法为sendKeys,即向输入框输入数据;操作值为admin,即被测试系统的登录用户名。The operation data includes operation method and operation value. The operation method is sendKeys, that is, input data into the input box; the operation value is admin, that is, the login user name of the tested system.
元素数据包括:用户名输入框定位方式:id,即通过html元素的id来查找定位该元素;用户名输入框定位字符串:username,即假设该系统中登录页面的html中用户名输入框的id为username。The element data includes: the user name input box positioning method: id, that is, the element is located by the id of the html element; the user name input box positioning string: username, that is, it is assumed that the user name input box in the html of the login page in the system is located. id is username.
校验数据包括:校验方式:equals,即判断校验实际值和预期值是否相等;预期值:admin。The verification data includes: verification method: equals, that is, to determine whether the actual value of the verification is equal to the expected value; expected value: admin.
用户输入一个完整的测试用例的所有步骤,所有数据存入数据库端。执行用例时服务器按顺序从数据库端取出测试步骤的数据并调用执行器,执行器首先根据映射表调用元素获取函数初始化元素,如根据定位方式id和定位字符串username,调用selenium获取元素函数在被测系统登录页面定位到用户名输入框。再根据操作方式字段sendKeys,通过映查询射表,调用的selenium的sendKeys(value)函数操作浏览器向登录页面的用户名输入框输入操作值admin。接下来执行器从登录页面用户名输入框获取实际文本为admin,从数据库获取校验方式为equals,校验预期值为admin,通过比对实际值和预期值相等,校验通过,将校验结果true写入数据库。测试人员通过用户图形接口可以实时查看测试场景的每个步骤的执行结果。The user enters all steps of a complete test case, and all data is stored in the database side. When the use case is executed, the server retrieves the data of the test steps from the database in order and calls the executor. The executor first calls the element according to the mapping table to obtain the function initialization element. For example, according to the positioning method id and the positioning string username, call selenium to obtain the element function. Navigate to the user name input box on the login page of the test system. Then, according to the operation mode field sendKeys, through the mapping query table, the call selenium's sendKeys(value) function operates the browser to enter the operation value admin into the user name input box of the login page. Next, the executor obtains the actual text from the user name input box on the login page as admin, obtains the verification method from the database as equals, and the verification expected value is admin. By comparing the actual value and the expected value, the verification is passed and the verification The result true is written to the database. Testers can view the execution results of each step of the test scenario in real time through the user graphical interface.
本发明实施例进一步给出一种通过网页录入数据实现WEB自动化测试的装置,如图10所示,所述装置包括:The embodiment of the present invention further provides a device for implementing WEB automated testing through web page entry data, as shown in FIG. 10 , the device includes:
配置模块:在服务器中配置selenium框架及执行器,所述执行器内部存储三张映射表,分别是页面控制器映射表、元素定位器映射表、元素控制器映射表,用于将数据库中存储的用例数据映射为由selenium框架调用的函数及与函数对应的参数;Configuration module: Configure the selenium framework and the executor in the server. The executor stores three mapping tables inside, which are the page controller mapping table, the element locator mapping table, and the element controller mapping table, which are used to store in the database. The use case data is mapped to the function called by the selenium framework and the parameters corresponding to the function;
录入模块:通过图形接口录入自动化测试用例各测试步骤的关键数据,所述关键数据包括控制数据、元素数据、校验数据,并将所述关键数据存储于数据库端;所述图形接口与待测web网页配置在不同的终端上;Input module: input the key data of each test step of the automated test case through the graphical interface, the key data includes control data, element data, verification data, and store the key data in the database; The web pages are configured on different terminals;
测试模块:通过图形接口发送执行命令,服务器中的执行器调用selenium框架驱动待测web网页加载所述关键数据以执行自动化测试,并利用加载的校验数据进行校验;Test module: send an execution command through a graphical interface, the executor in the server calls the selenium framework to drive the web page to be tested to load the key data to perform automated testing, and use the loaded verification data for verification;
查看结果模块:通过图形接口页面查看校验结果。View Results Module: View calibration results through the graphical interface page.
本发明实施例进一步给出一种通过网页录入数据实现WEB自动化测试的系统,包括:The embodiment of the present invention further provides a system for realizing WEB automated testing through web page input data, including:
处理器,用于执行多条指令;a processor for executing multiple instructions;
存储器,用于存储多条指令;memory for storing multiple instructions;
其中,所述多条指令,用于由所述存储器存储,并由所述处理器加载并执行如前所述的通过网页录入数据实现WEB自动化测试的方法。Wherein, the plurality of instructions are used to be stored by the memory, and loaded by the processor to execute the method for implementing WEB automated testing by entering data through a web page as described above.
本发明实施例进一步给出一种计算机可读存储介质,所述存储介质中存储有多条指令;所述多条指令,用于由处理器加载并执行如前所述的通过网页录入数据实现WEB自动化测试的方法。An embodiment of the present invention further provides a computer-readable storage medium, where a plurality of instructions are stored in the storage medium; the plurality of instructions are used to be loaded and executed by a processor, as described above, by entering data through a web page. WEB automated testing methods.
需要说明的是,在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。It should be noted that the embodiments of the present invention and the features of the embodiments may be combined with each other under the condition of no conflict.
在本发明所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined. Or it can be integrated into another system, or some features can be omitted, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware, or may be implemented in the form of hardware plus software functional units.
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机装置(可以是个人计算机,实体机服务器,或者网络云服务器等,需安装Windows或者Windows Server操作系统)执行本发明各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(RandomAccess Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The above-mentioned integrated units implemented in the form of software functional units can be stored in a computer-readable storage medium. The above-mentioned software functional units are stored in a storage medium, and include several instructions to make a computer device (which can be a personal computer, a physical machine server, or a network cloud server, etc., need to install Windows or Windows Server operating system) to execute each of the present invention. Some steps of the method described in the examples. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.
以上所述,仅是本发明的较佳实施例而已,并非对本发明作任何形式上的限制,依据本发明的技术实质对以上实施例所作的任何简单修改、等同变化与修饰,均仍属于本发明技术方案的范围内。The above are only preferred embodiments of the present invention, and do not limit the present invention in any form. Any simple modifications, equivalent changes and modifications made to the above embodiments according to the technical essence of the present invention still belong to the present invention. within the scope of the technical solution of the invention.
Claims (6)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010740552.1A CN111737152B (en) | 2020-07-29 | 2020-07-29 | Method and device for realizing WEB automated testing through web page entry data |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010740552.1A CN111737152B (en) | 2020-07-29 | 2020-07-29 | Method and device for realizing WEB automated testing through web page entry data |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111737152A CN111737152A (en) | 2020-10-02 |
| CN111737152B true CN111737152B (en) | 2020-11-20 |
Family
ID=72656356
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010740552.1A Active CN111737152B (en) | 2020-07-29 | 2020-07-29 | Method and device for realizing WEB automated testing through web page entry data |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111737152B (en) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113239298A (en) * | 2021-06-18 | 2021-08-10 | 北京邮电大学 | Automatic capturing and inputting method and device for automatic test elements |
| CN113656319A (en) * | 2021-08-25 | 2021-11-16 | 广东三维家信息科技有限公司 | Regression testing method and device, electronic equipment and storage medium |
| CN114064482A (en) * | 2021-11-17 | 2022-02-18 | 北京金堤科技有限公司 | Visual testing method and device, computer storage medium and electronic equipment |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109992496A (en) * | 2017-12-29 | 2019-07-09 | 北京京东尚科信息技术有限公司 | A data processing method and device for automated testing |
| CN111209217A (en) * | 2020-03-12 | 2020-05-29 | 苏州浪潮智能科技有限公司 | System software function testing method, device, equipment and storage medium |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6993748B2 (en) * | 2001-10-26 | 2006-01-31 | Capital One Financial Corporation | Systems and methods for table driven automation testing of software programs |
| US9575873B2 (en) * | 2013-09-13 | 2017-02-21 | Sap Se | Software testing system and method |
| CN104820640B (en) * | 2015-05-19 | 2018-07-24 | 广州华多网络科技有限公司 | A kind of webpage test method and device |
| CN106598869A (en) * | 2016-12-26 | 2017-04-26 | 北京京东金融科技控股有限公司 | Method and device for realizing automatic software testing and electronic equipment |
| CN107783902A (en) * | 2017-09-26 | 2018-03-09 | 甘肃万维信息技术有限责任公司 | A kind of Selenium automated testing methods and system from coding |
| CN109726112A (en) * | 2018-08-17 | 2019-05-07 | 平安普惠企业管理有限公司 | Traverse test method, unit and computer readable storage medium |
| CN110908895A (en) * | 2019-10-11 | 2020-03-24 | 深圳壹账通智能科技有限公司 | Page automated testing method, device, computer equipment and storage medium |
-
2020
- 2020-07-29 CN CN202010740552.1A patent/CN111737152B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109992496A (en) * | 2017-12-29 | 2019-07-09 | 北京京东尚科信息技术有限公司 | A data processing method and device for automated testing |
| CN111209217A (en) * | 2020-03-12 | 2020-05-29 | 苏州浪潮智能科技有限公司 | System software function testing method, device, equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111737152A (en) | 2020-10-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10768906B2 (en) | Multi-technology visual integrated data management and analytics development and deployment environment | |
| CN111737152B (en) | Method and device for realizing WEB automated testing through web page entry data | |
| JP7477572B2 (en) | AUTOMATED CONTROL OF DISTRIBUTED COMPUTING DEVICES - Patent application | |
| CN107608902A (en) | Routine interface method of testing and device | |
| CN115658529A (en) | Automatic testing method for user page and related equipment | |
| CN111858584A (en) | Metadata management method, system and storage medium | |
| US20250077204A1 (en) | Software library usage optimization | |
| CN111552648A (en) | Automatic verification method and system for application | |
| CN111444109B (en) | Mobile terminal UI automatic test method and system | |
| CN116166533A (en) | Interface testing method, device, terminal equipment and storage medium | |
| CN118820116B (en) | A method and device for quickly and automatically building system use cases based on mapping models | |
| CN113190463A (en) | Code testing method, node and system | |
| US20250077681A1 (en) | Correcting security vulnerabilities with generative artificial | |
| CN117914737A (en) | Mirror image resource testing method and device for network target range | |
| CN113515452B (en) | Automatic test method, system, electronic equipment and storage medium for application | |
| CN117762802A (en) | Automatic test method, device, equipment and storage medium | |
| CN112131091A (en) | Test method and device and electronic equipment | |
| CN115934559A (en) | The Test Method of Form Intelligence Test System | |
| US20180081665A1 (en) | Versioned intelligent offline execution of software configuration automation | |
| CN115599683A (en) | Automated testing method, device, equipment and storage medium | |
| CN114821604A (en) | Vehicle information processing method, device, equipment and medium based on RPA and AI | |
| US20250077189A1 (en) | Service design coordination among developers | |
| CN119377129B (en) | Integrated test method for simulating semiconductor device and EAP system and related device | |
| CN119537208B (en) | A test data generation platform, method, computer equipment, and storage medium | |
| CN114881751B (en) | Configuration method, system, electronic device and storage medium for financial scheduling tasks |
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 |