CN109739751A - Realize the method and system of webpage automatic test - Google Patents

Realize the method and system of webpage automatic test Download PDF

Info

Publication number
CN109739751A
CN109739751A CN201811557365.9A CN201811557365A CN109739751A CN 109739751 A CN109739751 A CN 109739751A CN 201811557365 A CN201811557365 A CN 201811557365A CN 109739751 A CN109739751 A CN 109739751A
Authority
CN
China
Prior art keywords
test
elemental motion
webpage
realizing
elemental
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.)
Withdrawn
Application number
CN201811557365.9A
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.)
Guiyang Longmaster Information and Technology Co ltd
Original Assignee
Guiyang Longmaster Information and 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 Guiyang Longmaster Information and Technology Co ltd filed Critical Guiyang Longmaster Information and Technology Co ltd
Priority to CN201811557365.9A priority Critical patent/CN109739751A/en
Publication of CN109739751A publication Critical patent/CN109739751A/en
Withdrawn legal-status Critical Current

Links

Abstract

The invention discloses a kind of method and system for realizing webpage automatic test, including encapsulation step: the operating process that webpage test needs to be implemented will be carried out and disassembled, then each process dismantling obtained is encapsulated as an elemental motion respectively, establishes elemental motion library;Assembled step: according to the motion flow of current webpage test operation to be tested, corresponding elemental motion is chosen from the elemental motion library and temporally axis is stitched together to obtain test action;Testing procedure: the test action is executed, test result is obtained.The present invention will use frequent method to encapsulate, and reduce code redundancy, improve availability and execution efficiency, form test frame, can be used for any web test item.

Description

Realize the method and system of webpage automatic test
Technical field
The present invention relates to a kind of method and system of webpage automatic test.
Background technique
People is simulated by calling directly selenium sentence using Python in webpage automatic test at present Work test process, such as: when logging in system by user, browser is opened, inputs username and password, then click " login " button i.e. Achievable register.The prior art such as CN106776343A, the interface provided by Selenium are realized and press ID, TAG_ The keywords such as NAME, NAME, CLASS_NAME, CSS_SELECTOR, LINK_TEXT, PARTIAL_LINK_TEXT, XPATH come Position a web page element;The process for going simulating hand to test by the interface that Selenium is provided again.
By taking the process of analog subscriber input " user name " as an example:
(1) " user name " input frame is positioned
(2) data in input frame are removed
(3) data are written for input frame
(4) if write-in failure, needs by judging sentence come throw exception
It can be seen that above this during assignment repeatedly can be made to input frame, code redundancy is more, and for different Webpage test will rewrite code and call Selenium interface, inefficiency, the exploitation to Selenium interface calling is ignorant of Personnel are unfriendly.
Summary of the invention
The present invention problem complicated, inflexible for use, multiplicity is high for automatic test written in code, will use frequent Method encapsulation, reduces code redundancy, improves availability and execution efficiency.
The technical scheme is that
A method of realizing webpage automatic test, comprising:
Encapsulation step: will carry out the operating process that webpage test needs to be implemented and disassemble, each process that then dismantling is obtained It is encapsulated as an elemental motion respectively, establishes elemental motion library;
Assembled step: it according to the motion flow of current webpage test operation to be tested, is chosen from the elemental motion library corresponding Elemental motion and temporally axis is stitched together to obtain test action;
Testing procedure: the test action is executed, test result is obtained.
The encapsulation of elemental motion is completed using the interface that Selenium is provided in encapsulation step.
Elemental motion is assembled into test action using Python in assembled step.
If lacking elemental motion required for current webpage test operation to be tested in elemental motion library, execute encapsulation step Suddenly, new elemental motion is supplemented into elemental motion library.
Judge that web page element whether there is or whether meet the function of preset value in testing procedure, can not find this default member When element or preset value are undesirable, throw exception prompt.
A kind of system for realizing webpage automatic test, including elemental motion library, elemental motion calling module and survey Action executing module is tried, stores the elemental motion decomposed from webpage test operating procedure in elemental motion library;Elemental motion Calling module is for calling elemental motion and being spliced into a complete test action;Test action execution module is for executing survey Examination movement, obtains test result.
Elemental motion in elemental motion library is constructed based on Selenium.
Elemental motion is assembled into test action by Python by elemental motion calling module.
Elemental motion library is extendible.
Judge that web page element whether there is or whether meet the function of preset value after having executed test action, can not find this When predicted elemental or undesirable preset value, throw exception prompt.
Beneficial effects of the present invention:
The present invention will use frequent method to encapsulate, and reduce code redundancy, improve availability and execution efficiency, form test block Frame can be used for any web test item.Without being concerned about the application method of base's code selenium, it need to only pass through Python language Speech calls function.These common operating process are encapsulated formation function, make the developer for developing test script Without being concerned about the call method of Selenium interface, is quickly developed, be simply easy to operate, when reducing learning cost and study Between;Simplified code improves operational efficiency, reduces code redundancy.
Detailed description of the invention:
Fig. 1 is using flow chart of the invention;
Fig. 2 is the comparison of existing procedure and process of the present invention.
Specific embodiment
Specific implementation of the invention is made a detailed description with reference to the accompanying drawings of the specification.
Embodiment 1: a method of realizing webpage automatic test, comprising:
Encapsulation step: will carry out the operating process that webpage test needs to be implemented and disassemble, each process that then dismantling is obtained It is encapsulated as an elemental motion respectively, establishes elemental motion library;
Assembled step: it according to the motion flow of current webpage test operation to be tested, is chosen from the elemental motion library corresponding Elemental motion and temporally axis is stitched together to obtain test action;
Testing procedure: the test action is executed, test result is obtained.
The encapsulation of elemental motion is completed using the interface that Selenium is provided in encapsulation step;The present invention is common Simulated operation is packaged into function by the interface for calling Selenium to provide.Such as: clicking, input, choose drop-down menu, obtain The elemental motions (function) such as various values.
Elemental motion is assembled into test action using Python in assembled step, i.e., is called and is sealed by Python The function of Selenium interface is filled.
If lacking elemental motion required for current webpage test operation to be tested in elemental motion library, execute encapsulation step Suddenly, new elemental motion is supplemented into elemental motion library.
Judge that web page element whether there is or whether meet the function of preset value in testing procedure, can not find this default member When element or preset value are undesirable, throw exception prompt.This process below such as:
When a executes a certain movement (such as click, input, choose drop-down menu, obtain various value operations), call in the present invention Function;
B. a scheduled time is waited, before and after movement to ensure that web page element is available;
Throw exception when c. can not find certain control;
D. check that web page element whether there is or whether meet the function of certain value, can not find this element or value is undesirable When, it throws abnormal;
E. test report is exported.
It is an above-mentioned example " by the process of analog subscriber input user name ", logging in system by user below When, browser is opened, inputs username and password, then click " login " button and register can be completed.
Now elaborated by " process of analog subscriber input user name ":
Test webpage is opened in a browser, the HTML code of webpage is checked by F12, positions the HTML of " user name " input frame Sentence is:
<input type="text" id="login_name" style="border: none;height: 24px; width: 180px;padding-top: 4px;" name="login_name" class="login_input" Autocomplete=" off " placeholder=" cell-phone number " >
4 elemental motions for writing automatic test script are: 1. positioning " user name " input frames;2. removing in input frame Data;3. data are written for input frame, if 4. write-in failures, need by judging sentence come throw exception.
There are many kinds of the methods for positioning " user name " input frame, such as ID, NAME, CLASS, XPATH etc..Here pass through it Middle one kind (NAME) elaborates, and is converted into automatic test script are as follows:
Browser.find_element_by_name (" login_name ") .clear () # position input frame simultaneously empties input Frame
Browser.find_element_by_name (" login_name ") .send_keys (' 1521111111 ') # input Data
(" { 0 } empties input data after input frame to try:self.log:<{ 1 }>content: { 2 }, time-consuming { 3 } seconds".format(success,css,text,time.time()-t1))except Exception:self.log(" { 0 } input data fails:<{ 1 }>content: { 2 }, time-consuming { 3 } seconds " .format (fail, css, text, Time.time ()-t1)) raise # judgement
Embodiment 2: a kind of system for realizing webpage automatic test, including elemental motion library, elemental motion calling module With test action execution module, the elemental motion decomposed from webpage test operating procedure is stored in elemental motion library;Substantially Action invocation module is for calling elemental motion and being spliced into a complete test action;Test action execution module is for holding Row test action, obtains test result.
Elemental motion in elemental motion library is constructed based on Selenium.
Elemental motion is assembled into test action by Python by elemental motion calling module.
Elemental motion library is extendible.
Judge that web page element whether there is or whether meet the function of preset value, can not find this predicted elemental or preset value When undesirable, throw exception prompt.

Claims (10)

1. a kind of method for realizing webpage automatic test, characterized by comprising:
Encapsulation step: will carry out the operating process that webpage test needs to be implemented and disassemble, each process that then dismantling is obtained It is encapsulated as an elemental motion respectively, establishes elemental motion library;
Assembled step: it according to the motion flow of current webpage test operation to be tested, is chosen from the elemental motion library corresponding Elemental motion and temporally axis is stitched together to obtain test action;
Testing procedure: the test action is executed, test result is obtained.
2. realizing the method for webpage automatic test according to claim 1, it is characterised in that: used in encapsulation step The interface that Selenium is provided completes the encapsulation of elemental motion.
3. realizing the method for webpage automatic test according to claim 1, it is characterised in that: use Python in assembled step Elemental motion is assembled into test action by language.
4. realizing the method for webpage automatic test according to claim 1, it is characterised in that: if lacking in elemental motion library current Elemental motion required for webpage test operation to be tested, then execute encapsulation step are supplemented new basic into elemental motion library Movement.
5. realizing the method for webpage automatic test according to claim 1, it is characterised in that: in testing procedure, executed test Check that web page element whether there is or whether meet the function of preset value, can not find this predicted elemental or preset value not after movement When meeting the requirements, throw exception prompt.
6. a kind of system for realizing webpage automatic test, it is characterised in that: called including elemental motion library, elemental motion Module and test action execution module store the elemental motion decomposed from webpage test operating procedure in elemental motion library; Elemental motion calling module is for calling elemental motion and being spliced into a complete test action;Test action execution module is used In executing test action, test result is obtained.
7. according to claim 6 for realizing the system of webpage automatic test, it is characterised in that: in elemental motion library Elemental motion is constructed based on Selenium.
8. according to claim 6 for realizing the system of webpage automatic test, it is characterised in that: mould is called in elemental motion Elemental motion is assembled into test action by Python by block.
9. according to claim 6 for realizing the system of webpage automatic test, it is characterised in that: elemental motion library can be expanded It fills.
10. according to claim 6 for realizing the system of webpage automatic test, it is characterised in that: it is dynamic to have executed test Check that web page element whether there is or whether meet the function of preset value, can not find this predicted elemental or preset value is not inconsistent after work When conjunction requires, throw exception prompt.
CN201811557365.9A 2018-12-19 2018-12-19 Realize the method and system of webpage automatic test Withdrawn CN109739751A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811557365.9A CN109739751A (en) 2018-12-19 2018-12-19 Realize the method and system of webpage automatic test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811557365.9A CN109739751A (en) 2018-12-19 2018-12-19 Realize the method and system of webpage automatic test

Publications (1)

Publication Number Publication Date
CN109739751A true CN109739751A (en) 2019-05-10

Family

ID=66360723

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811557365.9A Withdrawn CN109739751A (en) 2018-12-19 2018-12-19 Realize the method and system of webpage automatic test

Country Status (1)

Country Link
CN (1) CN109739751A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110727603A (en) * 2019-10-25 2020-01-24 重庆誉存大数据科技有限公司 Improved method for automatically testing positioning elements based on UI (user interface)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528297A (en) * 2016-01-29 2016-04-27 广州酷狗计算机科技有限公司 Method and device for testing web page
CN106095677A (en) * 2016-06-08 2016-11-09 上海爱数信息技术股份有限公司 The RESTful Webservice automatic interface testing method realized based on Robot Framework
CN106776343A (en) * 2017-01-13 2017-05-31 中国科学院软件研究所 A kind of web application automated test tool and method
CN107562626A (en) * 2017-08-31 2018-01-09 国家电网公司 A kind of method that encapsulation Selenium and Sikuli realizes Web automatic tests
US20180052764A1 (en) * 2016-08-16 2018-02-22 American Express Travel Related Services Company, Inc. Systems and methods for software testing and test management
CN108491319A (en) * 2018-02-11 2018-09-04 广州小百合信息技术有限公司 Web automated testing methods and system based on this method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528297A (en) * 2016-01-29 2016-04-27 广州酷狗计算机科技有限公司 Method and device for testing web page
CN106095677A (en) * 2016-06-08 2016-11-09 上海爱数信息技术股份有限公司 The RESTful Webservice automatic interface testing method realized based on Robot Framework
US20180052764A1 (en) * 2016-08-16 2018-02-22 American Express Travel Related Services Company, Inc. Systems and methods for software testing and test management
CN106776343A (en) * 2017-01-13 2017-05-31 中国科学院软件研究所 A kind of web application automated test tool and method
CN107562626A (en) * 2017-08-31 2018-01-09 国家电网公司 A kind of method that encapsulation Selenium and Sikuli realizes Web automatic tests
CN108491319A (en) * 2018-02-11 2018-09-04 广州小百合信息技术有限公司 Web automated testing methods and system based on this method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110727603A (en) * 2019-10-25 2020-01-24 重庆誉存大数据科技有限公司 Improved method for automatically testing positioning elements based on UI (user interface)

Similar Documents

Publication Publication Date Title
US10817409B2 (en) System and method for testing software applications in a software defined network
CN108733568A (en) Application testing method, device, equipment and readable storage medium storing program for executing
CN106649103B (en) A kind of method and system of Android application program Automated Black Box Testing
CN104407863B (en) Abstract control model programmer and method
US10489274B2 (en) Using emulation to disassociate verification from stimulus in functional test
EP1657634A2 (en) Test agent architecture
CN108347358A (en) The automatic test of cloud connection
US20090271351A1 (en) Rules engine test harness
CN110515848A (en) Automatization test system and automated testing method
CN103399814B (en) The method and device of automatic test
US20130298110A1 (en) Software Visualization Using Code Coverage Information
JP2000181750A (en) Software testing method
CA2170939A1 (en) Method and apparatus for displaying locations of errors detected inside software macro calls
EP1849077A2 (en) Test case automatic generation method for testing proactive gsm applications on sim card
CN108536593A (en) CS Framework Softwares automated testing method based on UI and system
CN110032519A (en) Cloud function adjustment method, device, computer equipment and storage medium
CN110221848A (en) APP method for updating pages, device, electronic equipment and storage medium
CN105556505A (en) Legacy system
CN111176629A (en) Application development method and device
CN110162457A (en) Test method, device, equipment and the storage medium of user interface
CN103631719A (en) Web automated testing method and device
US7469258B2 (en) Information processing method, apparatus and program in XML driven architecture
CN112988165A (en) Kubernetes-based interactive modeling method and device, electronic equipment and storage medium
CN114090117A (en) Configuration method, device, equipment and storage medium
CN109739751A (en) Realize the method and system of webpage automatic test

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20190510

WW01 Invention patent application withdrawn after publication