CN108897684A - A kind of feed-back type webpage automatic test script design method based on TestNG - Google Patents

A kind of feed-back type webpage automatic test script design method based on TestNG Download PDF

Info

Publication number
CN108897684A
CN108897684A CN201810685937.5A CN201810685937A CN108897684A CN 108897684 A CN108897684 A CN 108897684A CN 201810685937 A CN201810685937 A CN 201810685937A CN 108897684 A CN108897684 A CN 108897684A
Authority
CN
China
Prior art keywords
script
web page
testng
automatic test
test script
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810685937.5A
Other languages
Chinese (zh)
Inventor
史琦
李男
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai 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 Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810685937.5A priority Critical patent/CN108897684A/en
Publication of CN108897684A publication Critical patent/CN108897684A/en
Pending legal-status Critical Current

Links

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
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • 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
    • G06F11/3688Test 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

The present invention provides a kind of feed-back type automatic test script design method based on TestNG, includes the following steps:Write automatic test script;By the TestListerer tool of TestNG, each in script edit is substantially added to the script structure monitored and fed back;Webpage delays the problem of causing and repeats to execute previous step Script Action in capture execution, judges the type that reports an error.Step writes automatic test script, including:Test script progress layer-stepping is write;By each layer of progress modularized processing.Step by test script progress layer-stepping write including:It writes web page element index level, web page element positioning package layer, elemental basis operation encapsulated layer, testing procedure and writes layer.

Description

A kind of feed-back type webpage automatic test script design method based on TestNG
Technical field
The present invention relates to test script design fields, and in particular to a kind of feed-back type automation survey based on TestNG Training the design method.
Background technique
Webpage automatic test script frequently encounters that the webpage response time is too long or click speed is too fast causes when being executed Web displaying delay.It is embodied in:After clicking page elements or executing web page operation, since server response slowly causes Webpage, which does not show, should interface.
Such as:It is not jumped correctly after webpage clicking key or without response.When encountering this problem, if automatic test script Respective handling is not carried out then and will lead to script execution to report an error, specific mistake includes:It can not find web page element, element positioning does not exist In caching, element is invisible to lead to not the such as click
It is to re-execute entire script after capture is wrong to the existing listening mode of this problem in existing automatic test, this processing Mode not only consumes the plenty of time, more because preposition needed for the script of part without causing for error situation progress proper treatment Condition is unable to satisfy, thus the improvement of stability and implementing result not substantially to script.
Summary of the invention
In order to overcome the deficiencies in the prior art described above, the present invention provides a kind of feed-back type automation survey based on TestNG Training the design method, to solve the above technical problems.
The technical scheme is that:
A kind of feed-back type automatic test script design method based on TestNG, includes the following steps:
Write automatic test script;
By the TestListerer tool of TestNG, each in script edit is substantially added to the script monitored and fed back Structure;
Webpage delays the problem of causing and repeats to execute previous step Script Action in capture execution, judges the type that reports an error.
Further, step writes automatic test script, including:
Test script progress layer-stepping is write;
By each layer of progress modularized processing.
Further, step by test script progress layer-stepping write including:
It writes web page element index level, web page element positioning package layer, elemental basis operation encapsulated layer, testing procedure and writes layer.
Further, web page element index level, for the localization and expression formula of web page element to be separately stored as a webpage Element index library;Web page element positioning package layer, for page elements to be positioned and encapsulated according to Web page classifying;
Elemental basis operates encapsulated layer, for realizing the basic operation of web page element;Testing procedure writes layer, on calling One layer of webpage basic operation, complete operation module between
Testing procedure is completed in combination.
Further, the process of web page element index level is write:
It is stored by localization and expression formula with text mode and is appointed as positioning library and carry out using the volume of completion web page element index level It writes;
Localization and expression formula includes id localization and expression formula, css localization and expression formula or Xpath localization and expression formula;
Mode is when storage:Element term-localization and expression formula type-specific localization and expression, when calling, need to only specify element term Obtain specific localization method.
Further, the process for writing web page element positioning package layer includes:
S61:Required localization and expression formula is obtained from web page element index level;
S62:Element is positioned and encapsulated by using positioning command;
S63:All elements in the same page are categorized in the same program class;
S64:Initialize described program class;
S65:All elements in this page are directly acquired by the public variable of caller class.
Further, write elemental basis operation encapsulated layer process include:
S71:Write basic web page operation;
S72:Call the public variable of father net page element alignment layers;
S73:Modular classification arrangement is carried out to the operation in webpage;
S74:Web page operation step is write to each little module and is encapsulated into script.
Further, step passes through the TestListerer tool of TestNG, each in script edit is substantially added Add monitoring and the script structure fed back includes:
Attribute is added before each testcase of script, test listener is allow to monitor this test, for working as script When execution when the error occurs, the Assert order triggered in script reports an error.
Further, webpage delays the problem of causing and repeats to execute previous step Script Action in step capture execution, sentences The disconnected type that reports an error, including:
Webpage delays the problem of causing in capture execution;
The testcase for occurring reporting an error will be repeated automatically by TestListener tool, that is, repeats to wrap in this testcase The test action code contained.
Further, webpage delays the problem of causing and repeats to execute previous step Script Action in step capture execution, sentences The disconnected type that reports an error, specifically includes:
If Assert order causes the mistake of alarm that can not find element error, i.e. ElementNotFound, as network is delayed The caused page show it is incorrect, again execute operation can pass through, automatic test script will continue next Test action, and show that test result is to pass through after having executed all tests;
If Assert order causes the mistake of alarm not to be that webpage delays the problem of causing, can be in same position when executing again It sets and same mistake occurs, be judged as tested webpage there are problem, script will stop and report an error.
By the TestListerer tool of TestNG, each elemental motion in script edit is rewritten as monitoring and anti- The script structure of feedback captures webpage in executing and delays the problem of causing and repeat to execute previous step Script Action, filters out webpage Delay the problem of causing, script is made to continue to stablize execution.
As can be seen from the above technical solutions, the present invention has the following advantages that:Avoid the foot caused by delaying due to webpage This executive problem makes webpage can continue to smoothly respond, and enables script and tester by repeating previous action The problem of being enough absorbed in webpage itself.The time for largely repeating script is saved, automatic test efficiency is improved.
In addition, design principle of the present invention is reliable, structure is simple, has very extensive application prospect.
It can be seen that substantive distinguishing features outstanding and significantly improve compared with prior art, the present invention having, implementation Beneficial effect be also obvious.
Detailed description of the invention
Fig. 1 is a kind of feed-back type automatic test script design flow diagram based on TestNG;
Fig. 2 is to write web page element positioning package layer flow chart in automatic test script;
Fig. 3 is to write elemental basis in automatic test script to operate encapsulated layer flow chart.
Specific embodiment
The present invention will be described in detail with reference to the accompanying drawing and by specific embodiment, and following embodiment is to the present invention Explanation, and the invention is not limited to following implementation.
As shown in Figure 1, a kind of feed-back type automatic test script design method based on TestNG, includes the following steps:
S1:Write automatic test script;
S11:Test script progress layer-stepping is write;
Write web page element index level:It is stored by localization and expression formula with text mode and is appointed as positioning library and carried out using complete At writing for webpage element index layer;Localization and expression formula includes id localization and expression formula, css localization and expression formula or Xpath positioning table Up to formula;Mode is when storage:Element term-localization and expression formula type-specific localization and expression, when calling, need to only specify element term Obtain specific localization method.
As shown in Fig. 2, writing web page element positioning package layer:
S61:Required localization and expression formula is obtained from web page element index level;
S62:Element is positioned and encapsulated by using positioning command;
S63:All elements in the same page are categorized in the same program class;
S64:Initialize described program class;
S65:All elements in this page are directly acquired by the public variable of caller class.
As shown in figure 3, writing elemental basis operation encapsulated layer:
S71:Write basic web page operation;
S72:Call the public variable of father net page element alignment layers;
S73:Modular classification arrangement is carried out to the operation in webpage;
S74:Web page operation step is write to each little module and is encapsulated into script.
S12:By each layer of progress modularized processing.
S2:By the TestListerer tool of TestNG, by each in script edit substantially add monitoring and it is anti- The script structure of feedback;
Attribute is added before each testcase of script, test listener is allow to monitor this test, for working as script When execution when the error occurs, the Assert order triggered in script reports an error;
Specific code is as follows:
@Test(retryAnalyzer = com.xxx.retry.RetryListener.class)
Public void testcase1(){
// test action code
}
S3:Webpage delays the problem of causing and repeats to execute previous step Script Action in capture execution, judges the type that reports an error.
If Assert order causes the mistake of alarm that can not find element error, i.e. ElementNotFound, as network The page caused by delaying show incorrect, executes again and operates and can pass through, under automatic test script will continue One test action, and show that test result is to pass through after having executed all tests;
If Assert order causes the mistake of alarm not to be that webpage delays the problem of causing, can be in same position when executing again It sets and same mistake occurs, be judged as tested webpage there are problem, script will stop and report an error.
Wherein, web page element index level, for the localization and expression formula of web page element to be separately stored as a web page element Index database;Web page element positioning package layer, for page elements to be positioned and encapsulated according to Web page classifying;
Elemental basis operates encapsulated layer, for realizing the basic operation of web page element;Testing procedure writes layer, on calling One layer of webpage basic operation, complete operation module between
Testing procedure is completed in combination.
When the error occurs when script execution, whether webpage is delayed causing or other mistakes, in the script that will all set out Assert order reports an error, and will repeat automatically the testcase for occurring reporting an error by TestListener tool at this time, i.e., heavy The test action code for including in this multiple testcase.
The Assert order alarm triggering monitoring mechanism carried by TestNG may have two class reasons:If Assert is ordered It enables and the mistake of alarm is caused to be that can not find element error, i.e. ElementNotFound, i.e., the page caused by network is delayed is shown Incorrect, executing operation again by previous step can pass through;If mistake is not that webpage delays the problem of causing, Same mistake can occur in same position when executing again, be judged as that there are problem, script generals for tested webpage at this time It can stop and report an error.
If it is mistake is shown caused by network problem, after running succeeded again, automatic test script will continue Next test action, and show that test result is to pass through after having executed all tests;If not caused by network problem Relevant information it can be seen that error is shown after mistake, script stop.
Description and claims of this specification and term " first ", " second ", " third " " in above-mentioned attached drawing Four " etc.(If there is)It is to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should manage The data that solution uses in this way are interchangeable under appropriate circumstances, so as to the embodiment of the present invention described herein can in addition to Here the sequence other than those of diagram or description is implemented.In addition, term " includes " and " having " and their any deformation, It is intended to cover and non-exclusive includes.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, of the invention It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one The widest scope of cause.

Claims (10)

1. a kind of feed-back type automatic test script design method based on TestNG, which is characterized in that include the following steps:
Write automatic test script;
By the TestListerer tool of TestNG, each in script edit is substantially added to the script monitored and fed back Structure;
Webpage delays the problem of causing and repeats to execute previous step Script Action in capture execution, judges the type that reports an error.
2. a kind of feed-back type automatic test script design method based on TestNG according to claim 1, feature It is, step writes automatic test script, including:
Test script progress layer-stepping is write;
By each layer of progress modularized processing.
3. a kind of feed-back type automatic test script design method based on TestNG according to claim 2, feature Be, step by test script progress layer-stepping write including:
It writes web page element index level, web page element positioning package layer, elemental basis operation encapsulated layer, testing procedure and writes layer.
4. a kind of feed-back type automatic test script design method based on TestNG according to claim 3, feature It is,
Web page element index level, for the localization and expression formula of web page element to be separately stored as a web page element index database;
Web page element positioning package layer, for page elements to be positioned and encapsulated according to Web page classifying;
Elemental basis operates encapsulated layer, for realizing the basic operation of web page element;Testing procedure writes layer, on calling One layer of webpage basic operation, complete operation module between
Testing procedure is completed in combination.
5. a kind of feed-back type automatic test script design method based on TestNG according to claim 4, feature It is, writes the process of web page element index level:
It is stored by localization and expression formula with text mode and is appointed as positioning library and carry out using the volume of completion web page element index level It writes;
Localization and expression formula includes id localization and expression formula, css localization and expression formula or Xpath localization and expression formula;
Mode is when storage:Element term-localization and expression formula type-specific localization and expression, when calling, need to only specify element term Obtain specific localization method.
6. a kind of feed-back type automatic test script design method based on TestNG according to claim 5, feature It is, the process for writing web page element positioning package layer includes:
S61:Required localization and expression formula is obtained from web page element index level;
S62:Element is positioned and encapsulated by using positioning command;
S63:All elements in the same page are categorized in the same program class;
S64:Initialize described program class;
S65:All elements in this page are directly acquired by the public variable of caller class.
7. a kind of feed-back type automatic test script design method based on TestNG according to claim 6, feature It is, the process for writing elemental basis operation encapsulated layer includes:
S71:Write basic web page operation;
S72:Call the public variable of father net page element alignment layers;
S73:Modular classification arrangement is carried out to the operation in webpage;
S74:Web page operation step is write to each little module and is encapsulated into script.
8. a kind of feed-back type automatic test script design method based on TestNG according to claim 7, feature It is, step passes through the TestListerer tool of TestNG, each in script edit is substantially added and monitors and feeds back Script structure include:
Attribute is added before each testcase of script, test listener is allow to monitor this test, for working as script When execution when the error occurs, the Assert order triggered in script reports an error.
9. a kind of feed-back type automatic test script design method based on TestNG according to claim 8, feature It is, webpage delays the problem of causing and repeats to execute previous step Script Action in step capture execution, judges the type that reports an error, packet It includes:
Webpage delays the problem of causing in capture execution;
The testcase for occurring reporting an error will be repeated automatically by TestListener tool, i.e., includes in repeatedly testcase Test action code.
10. a kind of feed-back type automatic test script design method based on TestNG according to claim 9, feature It is, webpage delays the problem of causing and repeats to execute previous step Script Action in step capture execution, judges the type that reports an error, tool Body includes:
If Assert order causes the mistake of alarm that can not find element error, i.e. ElementNotFound, as network is delayed The caused page show it is incorrect, again execute operation can pass through, automatic test script will continue next Test action, and show that test result is to pass through after having executed all tests;
If Assert order causes the mistake of alarm not to be that webpage delays the problem of causing, can be in same position when executing again It sets and same mistake occurs, be judged as tested webpage there are problem, script will stop and report an error.
CN201810685937.5A 2018-06-28 2018-06-28 A kind of feed-back type webpage automatic test script design method based on TestNG Pending CN108897684A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810685937.5A CN108897684A (en) 2018-06-28 2018-06-28 A kind of feed-back type webpage automatic test script design method based on TestNG

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810685937.5A CN108897684A (en) 2018-06-28 2018-06-28 A kind of feed-back type webpage automatic test script design method based on TestNG

Publications (1)

Publication Number Publication Date
CN108897684A true CN108897684A (en) 2018-11-27

Family

ID=64346618

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810685937.5A Pending CN108897684A (en) 2018-06-28 2018-06-28 A kind of feed-back type webpage automatic test script design method based on TestNG

Country Status (1)

Country Link
CN (1) CN108897684A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634857A (en) * 2018-12-05 2019-04-16 东软集团股份有限公司 The method, apparatus and storage medium of test page object
CN111026638A (en) * 2019-10-29 2020-04-17 贝壳技术有限公司 Webpage automatic testing method and device, electronic equipment and storage medium
CN113505060A (en) * 2021-06-25 2021-10-15 北京控制工程研究所 Python automatic test script compiling method for spacecraft attitude and orbit control software
CN113704122A (en) * 2021-08-31 2021-11-26 优维科技(深圳)有限公司 UI (user interface) automatic test system and method based on standard interface

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354649A (en) * 2016-09-18 2017-01-25 郑州云海信息技术有限公司 Layered script design method for automated testing of webpages
CN107957948A (en) * 2017-12-07 2018-04-24 郑州云海信息技术有限公司 A kind of user interface automatic test device and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354649A (en) * 2016-09-18 2017-01-25 郑州云海信息技术有限公司 Layered script design method for automated testing of webpages
CN107957948A (en) * 2017-12-07 2018-04-24 郑州云海信息技术有限公司 A kind of user interface automatic test device and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
超级宝宝11: "TestNG TestCase失败重试", 《HTTP://WWW.51TESTING.COM/HTML/56/N-3717256.HTML》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634857A (en) * 2018-12-05 2019-04-16 东软集团股份有限公司 The method, apparatus and storage medium of test page object
CN111026638A (en) * 2019-10-29 2020-04-17 贝壳技术有限公司 Webpage automatic testing method and device, electronic equipment and storage medium
CN113505060A (en) * 2021-06-25 2021-10-15 北京控制工程研究所 Python automatic test script compiling method for spacecraft attitude and orbit control software
CN113505060B (en) * 2021-06-25 2023-11-10 北京控制工程研究所 Python automatic test script writing method for spacecraft attitude and orbit control software
CN113704122A (en) * 2021-08-31 2021-11-26 优维科技(深圳)有限公司 UI (user interface) automatic test system and method based on standard interface
CN113704122B (en) * 2021-08-31 2023-08-29 优维科技(深圳)有限公司 UI (user interface) automatic test system and method based on standard interface

Similar Documents

Publication Publication Date Title
CN108897684A (en) A kind of feed-back type webpage automatic test script design method based on TestNG
US7941707B2 (en) Gathering information for use in diagnostic data dumping upon failure occurrence
US11868226B2 (en) Load test framework
WO2021088724A1 (en) Testing method and apparatus
US7512954B2 (en) Method and mechanism for debugging a series of related events within a computer system
US7689610B2 (en) Automated grouping of messages provided to an application using string similarity analysis
Muccini et al. Using software architecture for code testing
CN109408357A (en) A kind of automatic interface testing method and device
US20070083630A1 (en) System and method for performance testing framework
US20150135158A1 (en) Isolated testing of distributed development projects
US9652353B2 (en) Monitoring business transaction failures involving database procedure calls
US20140109063A1 (en) Capturing test data associated with error conditions in software item testing
US8555234B2 (en) Verification of soft error resilience
Arora et al. Web application testing: A review on techniques, tools and state of art
CN106649084A (en) Function call information obtaining method and apparatus, and test device
US20080134205A1 (en) Automated grouping of messages provided to an application using execution path similarity analysis
CN101553769A (en) Method and system for tracking and monitoring computer applications
CN108228464B (en) Mobile application UI (user interface) testing framework based on data driving and implementation method thereof
US10255158B2 (en) Monitoring and diagnostics of business transaction failures
CN108228438A (en) The performance test methods and device of a kind of mobile terminal
Amalfitano et al. The DynaRIA tool for the comprehension of Ajax web applications by dynamic analysis
CN115658529A (en) Automatic testing method for user page and related equipment
WO2022033672A1 (en) Apparatus and method for injecting a fault into a distributed system
Ricca et al. Detecting anomaly and failure in web applications
CN107562619A (en) A kind of automatic traversal control method and terminal based on neuron models

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20181127

RJ01 Rejection of invention patent application after publication