CN105159825A - Web testing method and system - Google Patents
Web testing method and system Download PDFInfo
- Publication number
- CN105159825A CN105159825A CN201510514666.3A CN201510514666A CN105159825A CN 105159825 A CN105159825 A CN 105159825A CN 201510514666 A CN201510514666 A CN 201510514666A CN 105159825 A CN105159825 A CN 105159825A
- Authority
- CN
- China
- Prior art keywords
- content measurement
- tested
- input frame
- tested input
- web
- 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
Links
Abstract
The present invention provides a Web testing method and system. The Web testing method comprises: S1, inputting an URL address of a tested webpage and acquiring a source code of the webpage; S2, carrying out analysis positioning on the source code by XPath and determining all tested input boxes; and S3, acquiring the tested input boxes, receiving a length input by a user, randomly generating effective testing contents for the tested input boxes, filling the effective testing contents into the tested input boxes to carry out testing and storing a testing result obtained by testing. According to the Web testing method and system which are provided by the present invention, secondary development is carried out on the basis of selenium, works of source code analysis, element positioning and the like are packaged, the user directly faces an interface, testing can be automatically completed by setting parameters, both time and labor are saved and efficiency is high.
Description
Technical field
The present invention relates to a kind of measuring technology, particularly relate to a kind of Web method of testing and system.
Background technology
Because Web (webpage) application is directly related with user, usually need to bear again to operate in a large number for a long time, therefore the function of Web project and performance all have to pass through reliable checking.This will through the full test of Web project.Adopt manual test workload too large, consuming time for a long time and also error rate high.At this moment use some testing tools, test frame is necessary.Selenium is the automatic testing instrument that a kind of Web applies, by the various operations of analog subscriber to Web page, and can the exact reproduction software test personnel TestCases step of writing.Although Selenium is a very powerful automated test frame, the source code of Water demand webpage, and carries out element location, complicated operation, starts with more difficult, for tester, be familiar with instrument and need certain hour, be unfavorable for that test job is carried out.
Given this, how to reduce the development difficulty of Selenium, provide the automatic test efficiency of Selenium to become those skilled in the art's problem demanding prompt solution.
Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of Web method of testing and system, for solving large, the inefficient problem of Web test development difficulty in prior art.
For achieving the above object and other relevant objects, the invention provides a kind of Web method of testing, described Web method of testing comprises: step one, inputs the URL address of tested webpage, obtains the source code of webpage; Step 2, carries out analyzing and positioning by XPath to described source code, determines all tested input frames; Step 3, obtain tested input frame, receive the length of user's input, and be the effective content measurement of described tested input frame stochastic generation, and effective content measurement is filled in described tested input frame tests, the test result described test obtained is preserved.
Described Web method of testing also comprises: step 4, repeated execution of steps three, until Web test terminates.
Alternatively, determined all tested input frames are preserved by input frame array.
Alternatively, the specific implementation of the effective content measurement of stochastic generation comprises: stochastic generation content measurement, and the validity determining generated content measurement.
Alternatively, determine that the validity of generated content measurement comprises: when described content measurement is for time empty, determine that described content measurement is invalid; Or when the length of described content measurement exceedes the length of user's input, determine that described content measurement is invalid; Or when described content measurement comprises special character, determine that described content measurement is invalid; Otherwise, determine that described content measurement is effective content measurement.
Alternatively, when being related between two tested input frames, only when the content measurement that previous tested input frame is inserted is effective, just can insert the content measurement of a rear tested input frame.
The present invention also provides a kind of Web test macro, and described Web test macro comprises: test webpage source code obtains module, for inputting the URL address of tested webpage, obtains the source code of webpage; Tested input frame determination module, for carrying out analyzing and positioning by XPath to described source code, determines all tested input frames; Tested input frame test module, for obtaining tested input frame, receiving the length of user's input, and being the effective content measurement of described tested input frame stochastic generation, and effective content measurement is filled in described tested input frame tests, the test result described test obtained is preserved.
Alternatively, tested input frame determination module preserves determined all tested input frames by input frame array.
Alternatively, the specific implementation of the effective content measurement of stochastic generation comprises: stochastic generation content measurement, and the validity determining generated content measurement.
Alternatively, determine that the validity of generated content measurement comprises: when described content measurement is for time empty, determine that described content measurement is invalid; Or when the length of described content measurement exceedes the length of user's input, determine that described content measurement is invalid; Or when described content measurement comprises special character, determine that described content measurement is invalid; Otherwise, determine that described content measurement is effective content measurement.
Alternatively, tested input frame test module also for: when being related between two tested input frames, only when the content measurement that previous tested input frame is inserted is effective, just can insert the content measurement of a rear tested input frame.
As mentioned above, a kind of Web method of testing of the present invention and system, have following beneficial effect: carry out secondary development based on selenium, will analyze source code, the Work Packages such as element location are got up, and user is direct in the face of interface, setup parameter, just can automatically complete, time saving and energy saving, and efficiency is higher.The present invention is that numerous and diverse operation encapsulated, tester only needs to set parameter, and instrument just can complete the test to input frame automatically based on selenium exploitation.Easy to use, simple to operate.
Accompanying drawing explanation
Fig. 1 is shown as the schematic flow sheet of an embodiment of Web method of testing of the present invention.
Fig. 2 is shown as the module diagram of an embodiment of Web test macro of the present invention.
Element numbers explanation
1Web test macro
11 test webpage source codes obtain module
12 tested input frame determination modules
13 tested input frame test modules
S1 ~ S3 step
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this instructions can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this instructions also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.
It should be noted that, the diagram provided in the present embodiment only illustrates basic conception of the present invention in a schematic way, then only the assembly relevant with the present invention is shown in graphic but not component count, shape and size when implementing according to reality is drawn, it is actual when implementing, and the kenel of each assembly, quantity and ratio can be a kind of change arbitrarily, and its assembly layout kenel also may be more complicated.
The invention provides a kind of Web method of testing.In one embodiment, as shown in Figure 1, described Web method of testing comprises:
Step S1, inputs the URL address of tested webpage, obtains the source code of webpage.In one embodiment, in system interface, input the URL address of tested Web (webpage), click " acquisition source code " and then the source code of webpage is all downloaded, and be automatically saved in local file.
Step S2, carries out analyzing and positioning by XPath to described source code, determines all tested input frames.Particularly, system carries out the tested input frame of analyzing and positioning, for testing below by Xpath.Xpath is the plain mode that a kind of in Selenium test finds the element not with specific ID or title.If know an attribute outside ID or title, so directly use attribute=value location element.If only know some specific parts of property value, so use contains (attribute, value) location element.If the attribute that element is not specified, so utilize Firebug to search for nearest father's element with specified attribute, then use Xpath from this element, locate that element wanting to find.In one embodiment, determined all tested input frames are preserved by input frame array.Each element in input frame array is a determined tested input frame.
Step S3, obtain tested input frame, receive the length of user's input, and be the effective content measurement of described tested input frame stochastic generation, and effective content measurement is filled in described tested input frame tests, the test result described test obtained is preserved.The specific implementation of the effective content measurement of stochastic generation comprises: stochastic generation content measurement, and the validity determining generated content measurement.In one embodiment, determine that the validity of generated content measurement comprises: when described content measurement is for time empty, determine that described content measurement is invalid; Or when the length of described content measurement exceedes the length of user's input, determine that described content measurement is invalid; Or when described content measurement comprises special character, determine that described content measurement is invalid; Otherwise, determine that described content measurement is effective content measurement.In one embodiment, follow the length according to user's input, system call random unit stochastic generation letter, numeral, special character, or the combination of arbitrary form; Determine the validity of generated content measurement: first determine whether sky; For sky then illustrates invalid, need to regenerate content measurement; If be not empty, then judge whether length meets web designing requirement further, when the length of described content measurement exceedes the length of user's input, the designing requirement not meeting Web is described, content measurement is invalid, needs to regenerate content measurement; When the length of described content measurement is no more than the length of user's input, the designing requirement meeting Web is described, then judge whether further to comprise special character, if comprise special character, then content measurement undesirable (content measurement is invalid) is described, needs to regenerate content measurement; If content measurement does not comprise special character, then illustrate that this content measurement is effective.In one embodiment, when being related between two tested input frames, only when the content measurement that previous tested input frame is inserted is effective, just can insert the content measurement of a rear tested input frame.Described Web method of testing also comprises: step 4, repeated execution of steps S3, until complete Web test.In one embodiment, the content measurement of stochastic generation also can first be filled in tested input frame, and then detect the validity of this content measurement, when inserted content measurement is invalid, again stochastic generation content measurement, be filled into the validity detecting content measurement in tested input frame, until the content measurement inserted is effective.
The present invention also provides a kind of Web test macro.In one embodiment, as shown in Figure 2, described Web test macro 1 comprise 11, tested input frame determination module 12 and tested input frame test module 13.Wherein:
Test webpage source code obtains module 11 for inputting the URL address of tested webpage, obtains the source code of webpage.In one embodiment, obtain at test webpage source code the URL address inputting tested Web (webpage) in the interface of module 11, click " acquisition source code " and then the source code of webpage is all downloaded, and be automatically saved in local file.
Tested input frame determination module 12 obtains module 11 with test webpage source code and is connected, and for carrying out analyzing and positioning by XPath to described source code, determines all tested input frames.Particularly, tested input frame determination module 12 carries out the tested input frame of analyzing and positioning, for testing by Xpath below to the source code that test webpage source code obtains module 11 acquisition.Xpath is a kind of plain mode finding element not with specific ID or title.If know an attribute outside ID or title, so directly use attribute=value location element.If only know some specific parts of property value, so use contains (attribute, value) location element.If the attribute that element is not specified, so utilize Firebug to search for nearest father's element with specified attribute, then use Xpath from this element, locate that element wanting to find.In one embodiment, determined all tested input frames are preserved by input frame array.Each element in input frame array is a determined tested input frame.
Tested input frame test module 13 is connected with tested input frame determination module 12, for obtaining tested input frame, receive the length of user's input, and be the effective content measurement of described tested input frame stochastic generation, and effective content measurement is filled in described tested input frame tests, the test result described test obtained is preserved.The specific implementation of the effective content measurement of stochastic generation comprises: stochastic generation content measurement, and the validity determining generated content measurement.In one embodiment, determine that the validity of generated content measurement comprises: when described content measurement is for time empty, determine that described content measurement is invalid; Or when the length of described content measurement exceedes the length of user's input, determine that described content measurement is invalid; Or when described content measurement comprises special character, determine that described content measurement is invalid; Otherwise, determine that described content measurement is effective content measurement.In one embodiment, follow the length according to user's input, system call random unit stochastic generation letter, numeral, special character, or the combination of arbitrary form; Determine the validity of generated content measurement: first determine whether sky; For sky then illustrates invalid, need to regenerate content measurement; If be not empty, then judge whether length meets web designing requirement further, when the length of described content measurement exceedes the length of user's input, the designing requirement not meeting Web is described, content measurement is invalid, needs to regenerate content measurement; When the length of described content measurement is no more than the length of user's input, the designing requirement meeting Web is described, then judge whether further to comprise special character, if comprise special character, then content measurement undesirable (content measurement is invalid) is described, needs to regenerate content measurement; If content measurement does not comprise special character, then illustrate that this content measurement is effective.In one embodiment, when being related between two tested input frames, only when the content measurement that previous tested input frame is inserted is effective, just can insert the content measurement of a rear tested input frame.In one embodiment, in tested input frame test module 13, the content measurement of stochastic generation also can first be filled in tested input frame, and then detect the validity of this content measurement, when inserted content measurement is invalid, again stochastic generation content measurement, be filled into the validity detecting content measurement in tested input frame, until the content measurement inserted is effective.Tested input frame test module 13 can multiple exercise, completes Web test as required.
In sum, a kind of Web method of testing of the present invention and system, have following beneficial effect: carry out secondary development based on selenium, will analyze source code, the Work Packages such as element location are got up, and user is direct in the face of interface, setup parameter, just can automatically complete, time saving and energy saving, and efficiency is higher.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.
Claims (10)
1. a Web method of testing, is characterized in that, described Web method of testing comprises:
Step one, inputs the URL address of tested webpage, obtains the source code of webpage;
Step 2, carries out analyzing and positioning by XPath to described source code, determines all tested input frames;
Step 3, obtain tested input frame, receive the length of user's input, and be the effective content measurement of described tested input frame stochastic generation, and effective content measurement is filled in described tested input frame tests, the test result described test obtained is preserved.
2. Web method of testing according to claim 1, is characterized in that: determined all tested input frames are preserved by input frame array.
3. Web method of testing according to claim 1, is characterized in that: the specific implementation of the effective content measurement of stochastic generation comprises: stochastic generation content measurement, and the validity determining generated content measurement.
4. Web method of testing according to claim 3, is characterized in that: determine that the validity of generated content measurement comprises: when described content measurement is for time empty, determine that described content measurement is invalid; Or when the length of described content measurement exceedes the length of user's input, determine that described content measurement is invalid; Or when described content measurement comprises special character, determine that described content measurement is invalid; Otherwise, determine that described content measurement is effective content measurement.
5. Web method of testing according to claim 1, is characterized in that: when being related between two tested input frames, only when the content measurement that previous tested input frame is inserted is effective, just can insert the content measurement of a rear tested input frame.
6. a Web test macro, is characterized in that: described Web test macro comprises: test webpage source code obtains module, for inputting the URL address of tested webpage, obtains the source code of webpage; Tested input frame determination module, for carrying out analyzing and positioning by XPath to described source code, determines all tested input frames; Tested input frame test module, for obtaining tested input frame, receiving the length of user's input, and being the effective content measurement of described tested input frame stochastic generation, and effective content measurement is filled in described tested input frame tests, the test result described test obtained is preserved.
7. Web test macro according to claim 6, is characterized in that: tested input frame determination module preserves determined all tested input frames by input frame array.
8. Web test macro according to claim 6, is characterized in that: the specific implementation of the effective content measurement of stochastic generation comprises: stochastic generation content measurement, and the validity determining generated content measurement.
9. Web test macro according to claim 8, is characterized in that: determine that the validity of generated content measurement comprises: when described content measurement is for time empty, determine that described content measurement is invalid; Or when the length of described content measurement exceedes the length of user's input, determine that described content measurement is invalid; Or when described content measurement comprises special character, determine that described content measurement is invalid; Otherwise, determine that described content measurement is effective content measurement.
10. Web test macro according to claim 6, it is characterized in that: tested input frame test module also for: when being related between two tested input frames, only when the content measurement that previous tested input frame is inserted is effective, just can insert the content measurement of a rear tested input frame.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510514666.3A CN105159825A (en) | 2015-08-20 | 2015-08-20 | Web testing method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510514666.3A CN105159825A (en) | 2015-08-20 | 2015-08-20 | Web testing method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105159825A true CN105159825A (en) | 2015-12-16 |
Family
ID=54800687
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510514666.3A Pending CN105159825A (en) | 2015-08-20 | 2015-08-20 | Web testing method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105159825A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101526919A (en) * | 2009-04-29 | 2009-09-09 | 福建星网锐捷网络有限公司 | Method for generating script files to test Web application software and device thereof |
US20120036580A1 (en) * | 2010-07-19 | 2012-02-09 | Sitelock, Llc | Selective website vulnerability and infection testing |
US20130086554A1 (en) * | 2011-09-29 | 2013-04-04 | Sauce Labs, Inc. | Analytics Driven Development |
CN103377127A (en) * | 2012-04-28 | 2013-10-30 | 阿里巴巴集团控股有限公司 | Development testing system, testing method and device for webpage product |
CN104391786A (en) * | 2014-10-31 | 2015-03-04 | 任子行网络技术股份有限公司 | Webpage automatic test system and method thereof |
CN104461901A (en) * | 2014-12-23 | 2015-03-25 | 浪潮(北京)电子信息产业有限公司 | Method and system for automatically generating test case |
-
2015
- 2015-08-20 CN CN201510514666.3A patent/CN105159825A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101526919A (en) * | 2009-04-29 | 2009-09-09 | 福建星网锐捷网络有限公司 | Method for generating script files to test Web application software and device thereof |
US20120036580A1 (en) * | 2010-07-19 | 2012-02-09 | Sitelock, Llc | Selective website vulnerability and infection testing |
US20130086554A1 (en) * | 2011-09-29 | 2013-04-04 | Sauce Labs, Inc. | Analytics Driven Development |
CN103377127A (en) * | 2012-04-28 | 2013-10-30 | 阿里巴巴集团控股有限公司 | Development testing system, testing method and device for webpage product |
CN104391786A (en) * | 2014-10-31 | 2015-03-04 | 任子行网络技术股份有限公司 | Webpage automatic test system and method thereof |
CN104461901A (en) * | 2014-12-23 | 2015-03-25 | 浪潮(北京)电子信息产业有限公司 | Method and system for automatically generating test case |
Non-Patent Citations (2)
Title |
---|
伯格曼,普锐斯克: "《开发高质量PHP框架与应用的实际案例解析》", 31 May 2012, 北京:清华大学出版社 * |
肖丁,修佳鹏: "《软件工程模型与方法第2版》", 31 August 2014, 北京邮电大学出版社 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103150238B (en) | A kind of service request processing method, simulated performance method of testing and device | |
US10422733B2 (en) | Method and device for testing wettability of dense oil reservoir | |
US9367427B2 (en) | Embedding and executing trace functions in code to gather trace data | |
CN102799529B (en) | A kind of dynamic binary code method for generating test case | |
CN105426309A (en) | Test case automatic generation method and apparatus | |
CN107659455B (en) | Method, storage medium, device and system for Mock data of iOS (internet operating system) end | |
CN103678105A (en) | Page code testing method and device | |
CN105138461A (en) | Interface testing method and device for application program | |
CN105117341A (en) | Distributed automatic test case generation method based on dynamic symbolic execution | |
CN105095088A (en) | Calculator automatic test method and test system based on uiautomator test framework | |
CN105279092A (en) | Software testing method and apparatus | |
CN105302717A (en) | Detection method and apparatus for big data platform | |
CN101873234A (en) | Network card performance testing system and method | |
CN108733404A (en) | A kind of accurate reverse engineering approach for FPGA firmwares | |
CN105158673B (en) | A kind of generation method and device of ATE boards file | |
CN104601768A (en) | Android mobile phone automatic testing system and testing method thereof | |
CN110908915B (en) | Test coverage rate display method and device and computer system | |
CN106383789A (en) | Software interface test method and software interface test system | |
KR20180009589A (en) | Apparatus and method for analyzing programs | |
CN101201787A (en) | System and method for debugging software program | |
CN108874656A (en) | Code test method, device, readable storage medium storing program for executing and computer equipment | |
CN104239055A (en) | Method for detecting complexity of software codes | |
CN105138458A (en) | Method and system for recording automatic testing scripts by combining intelligent terminal and computer terminal | |
CN105159825A (en) | Web testing method and system | |
CN107622013B (en) | Distributed system testing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20151216 |