CN107678952A - A kind of method and system of Webpage element operation - Google Patents

A kind of method and system of Webpage element operation Download PDF

Info

Publication number
CN107678952A
CN107678952A CN201710865700.0A CN201710865700A CN107678952A CN 107678952 A CN107678952 A CN 107678952A CN 201710865700 A CN201710865700 A CN 201710865700A CN 107678952 A CN107678952 A CN 107678952A
Authority
CN
China
Prior art keywords
webpage
element operation
module
waits
dom
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
CN201710865700.0A
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 CN201710865700.0A priority Critical patent/CN107678952A/en
Publication of CN107678952A publication Critical patent/CN107678952A/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/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/349Performance evaluation by tracing or monitoring for interfaces, buses
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking

Abstract

The invention discloses a kind of method and system of Webpage element operation, method includes step:S1, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;S2, element is operated using testing tool;Whether S3, detection elements operation succeed, if not successfully, persistently carrying out element operation until element operation success;S4, S1 S3 operating procedures are encapsulated into test case.System includes element acquisition module, and the mode waited using display waits element to occur, and waits elementary state to be changed into operable;Element operation module, element is operated using testing tool;Element processing module, whether succeed for detection elements operation, if not successfully, persistently carrying out element operation until element operation success;Encapsulation process module, for element to be obtained, element operation, element processing be encapsulated into test case.The present invention saves the testing time, and ensures that Webpage element occurs.

Description

A kind of method and system of Webpage element operation
Technical field
The present invention relates to field of computer technology, specifically a kind of method and system of Webpage element operation.
Background technology
In webUI (Website User Interface, browser interface) automatic test course, using more Test mode is that the framework based on selenium (selenium is a kind of instrument applied to web tests) is realized.Its is main Operating principle be by driving the coherent element on webpage, imitate manually operated on webpage, and operation produced by script Raw result is verified, so as to reach the purpose of automatic test.
In actual mechanical process, some stubborn problems are often run into, most common is exactly that can not find page elements The problem of.It is mainly positioned by dynamic id does not switch less than element, iframe (label in webpage), position less than element, A kind of xpath (web page element describes method) descriptions mistake, the page cause without the reason such as loading in time.Dynamic id positioning less than Element, iframe do not switch, these wrong reasons of xpath descriptions can be evaded by script mode.But the page does not have Loading in time causes the solution that can not find element often less effective.
In the prior art it is main using fixed wait by the way of, such as grade one second either two seconds or more before looking for element It is more.Time poorly controls, and the stand-by period is long, can cause waste of time, too short that webpage loading can not cause.
The content of the invention
It is an object of the invention to provide a kind of method and system of Webpage element operation, for solving existing test The acquisition time bad grasp of middle element, waste the problem of testing time.
The technical solution adopted for the present invention to solve the technical problems is:A kind of method of Webpage element operation, bag Include following steps:
S1, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;
S2, element is operated using testing tool;
Whether S3, detection elements operation succeed, if not successfully, persistently carrying out element operation until element operation success;
S4, S1-S3 operating procedures are encapsulated into test case.
Further, the process for waiting dom loadeds is also included before step S1, by the change for detecting dom attributes Judge dom load condition.
Further, the detailed process of the display wait is:
Stand-by period is set;
Within waiting time, detect whether occur waiting element;
If so, then terminate to wait;
If it is not, then continuing to detect, after the stand-by period is set, prompt to wait failure.
Further, element is operated by calling testing tool to operate the interface of element, the operation bag to element Double-click is included, clicks, input text and selection.
Further, step S3 specific implementation process is:
Whether succeeded using try-catch structure detections element operation;
If so, pass directly in next step;
If it is not, the process that then cyclic elements operates, until detection elements operate successfully, goes in next step.
A kind of system of Webpage element operation, including
Element acquisition module, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;
Element operation module, element is operated using testing tool;
Element processing module, whether succeed for detection elements operation, if not successfully, persistently carrying out element operation until member Element operates successfully;
Encapsulation process module, for element acquisition module, element operation module and element processing module to be encapsulated into test In use-case.
Further, the system also includes webpage acquisition module, and the webpage acquisition module is by detecting dom attributes Change judges dom load condition, waits dom loadeds.
The effect provided in the content of the invention is only the effect of embodiment, rather than whole effects that invention is all, above-mentioned A technical scheme in technical scheme has the following advantages that or beneficial effect:
1st, the mode waited by using display waits element appearance and element operable respectively, when setting most long wait Between, whether continuous detection elements occur or operable within the stand-by period, if so, then directly jumping out wait, carry out next step Operation, saves the time, and ensures that Webpage element occurs and operable.
2nd, dom load condition is detected by detecting the change of dom attributes, waits dom loading completions to carry out again next The operation of step, further ensure the appearance of test elements.
3rd, after element operation terminates, judge whether element operation succeeds, if it fails, the operation of cyclic elements, until Element operation success, ensure that the correctness of element operation link, after detection elements operate successfully, carry out element operation envelope Dress, and applied in test case, ensure the reliability of test case.
Brief description of the drawings
Fig. 1 is the schematic flow sheet of the inventive method one embodiment;
Fig. 2 is the schematic flow sheet of another embodiment of the inventive method;
Fig. 3 is the structural representation of present system one embodiment;
Fig. 4 is the structural representation of another embodiment of present system.
Embodiment
For the technical characterstic for illustrating this programme can be understood, below by embodiment, and its accompanying drawing is combined, to this hair It is bright to be described in detail.Following disclosure provides many different embodiments or example is used for realizing the different knots of the present invention Structure.In order to simplify disclosure of the invention, hereinafter the part and setting of specific examples are described.In addition, the present invention can be with Repeat reference numerals and/or letter in different examples.This repetition is that for purposes of simplicity and clarity, itself is not indicated Relation between various embodiments are discussed and/or set.It should be noted that part illustrated in the accompanying drawings is not necessarily to scale Draw.Present invention omits the description to known assemblies and treatment technology and process to avoid being unnecessarily limiting the present invention.
As shown in figure 1, a kind of one embodiment of the method for Webpage element operation of the present invention, including following step Suddenly:
S1, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;
S2, element is operated using testing tool;
Whether S3, detection elements operation succeed, if not successfully, persistently carrying out element operation until element operation success;
S4, S1-S3 operating procedures are encapsulated into test case.
In step S1, the exercisable wait of wait and elementary state occurred to element uses the mode for showing and waiting, The process that display waits is the setting stand-by period;Within waiting time, detect whether occur waiting element;If so, then terminate Wait;If it is not, then continuing to detect, after the stand-by period is set, prompt to wait failure.
Display is waited for illustrating:Setting waits until that the time is 10s, within 10s, if element, table can be found Show and wait successfully, if it exceeds 10s, represents to wait failure.It is compared to the difference commonly waited:It is common to wait 10s, be Operated again after 10s.Display wait is in 10s, such as the 3rd second finds element, directly terminates to wait, during saving Between.
Appearance and the wait exercisable process of element to above-mentioned wait element are illustrated:The meaning that element occurs Think:For example in the case that webpage is very slow, the page is bit by bit to start loading, and loading a bit, illustrates there is Partial Elements appearance .The exercisable meaning of element:Such as have individual button on the page,, can although this button occurs when loading slow obtain It is able to not can click on, in some instances it may even be possible to be to occur in a manner of a text, it is exactly that button directly occurs that exercisable situation, which is, , and can be clicked on.
In step S2, the testing tool of the present embodiment is webdriver testing tools, by calling webdriver to operate The interface of element operates to element, wherein the operation to element includes double-clicking, clicking, inputting text and selection etc..
In step S3, whether succeeded using try-catch structure detections element operation;If so, then element is operated; If it is not, the process that then cyclic elements operates, is operated successfully to detection elements.Webdriver is operated element by the process of encapsulation Interface combination step S1~S3 operation composition one code root module, subsequently when calling element operation, directly invoke encapsulation Good module, avoid due to can not find element and the problem of can not operate.
In step S4, packaged element operation is applied in test case, ensures the reliability of test case, rear It is continuous when use test case, more smoothly, the progress of accelerated test, and reduction error probability.
As shown in Fig. 2 a kind of another embodiment of Webpage element operation method of the present invention, comprises the following steps:
S0, wait dom (Document Object Model, DOM Document Object Model) loaded;
S1, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;
S2, element is operated using testing tool;
Whether S3, detection elements operation succeed, if not successfully, persistently carrying out element operation until element operation success;
S4, S0-S3 operating procedures are encapsulated into test case.
In step S0, the change by detecting dom attributes judges dom load condition, as dom attributes are changed, Then show that dom loadings are completed, carry out the operation of next step.Carry out judging whether the page has loaded for example with the mode of js scripts Into, circulated using one, such as wait within 6 minutes, this 6 minutes, whether the attribute every the dom of detection in 2 seconds occurs Change, in the event of change, circulation is just jumped out, terminate to wait.
Step S1~S4 specific implementation process is same as the previously described embodiments, and therefore not to repeat here.
As shown in figure 3, a kind of one embodiment of Webpage element operation system of the present invention, the system is included successively Element acquisition module 1, element operation module 2, element processing module 3 and the encapsulation process module 4 of connection.
Wherein element acquisition module 1 using display wait mode wait element to occur, and wait elementary state to be changed into can Operation;Element operation module 2 utilizes testing tool operation element;Element processing module 3 is used for whether detection elements operation to succeed, After element operation success, element operation is packaged;Encapsulation process module 4 is used to packaged element operation being applied to In test case.
The mode that wait is shown in element acquisition module 1 is the setting stand-by period;Within waiting time, detect whether out Now wait element;If so, then terminate to wait;If it is not, then continuing to detect, after the stand-by period is set, prompt to wait failure.
Operation of the element operation module 2 to element includes double-clicking, clicking, inputting text and selection etc..
Whether element processing module 3 is succeeded by try-catch structure detections element operation, wherein try-catch structures It is a kind of program structure.
Element acquisition module 1, element operation module 2, element processing module 3 are encapsulated into test and used by encapsulation process module 4 In example, ensure the reliability of test case, when subsequently using test case, more smoothly, the progress of accelerated test, and reduce Error probability.
As shown in figure 4, a kind of another embodiment of Webpage element operation system of the present invention, in a upper embodiment On the basis of, the system of the present embodiment also includes the webpage acquisition module 5 being connected with element acquisition module 1, and webpage acquisition module 5 is logical The change for crossing detection dom attributes judges dom load condition to wait dom loadeds.Enter for example with the mode of js scripts Row judges whether the page loads completion, using a circulation, such as waits within 6 minutes, this 6 minutes, and one was detected every 2 seconds Whether secondary dom attribute changes, and in the event of change, just jumps out circulation, terminates to wait.Further ensure webpage page The appearance of surface element.
Simply the preferred embodiment of the present invention described above, for those skilled in the art, Without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications are also regarded as this hair Bright protection domain.

Claims (7)

1. a kind of method of Webpage element operation, it is characterized in that:Comprise the following steps:
S1, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;
S2, element is operated using testing tool;
Whether S3, detection elements operation succeed, if not successfully, persistently carrying out element operation until element operation success;
S4, S1-S3 operating procedures are encapsulated into test case.
2. a kind of method of Webpage element operation according to claim 1, it is characterized in that:Also include before step S1 The process of dom loadeds is waited, the change by detecting dom attributes judges dom load condition.
3. a kind of method of Webpage element operation according to claim 1 or 2, it is characterized in that:The display waits Detailed process be:
Stand-by period is set;
Within waiting time, detect whether occur waiting element;
If so, then terminate to wait;
If it is not, then continuing to detect, after the stand-by period is set, prompt to wait failure.
4. a kind of method of Webpage element operation according to claim 1 or 2, it is characterized in that:Tested by calling The interface of tool operation element operates to element, and the operation to element includes double-clicking, clicking, inputting text and selection.
5. a kind of method of Webpage element operation according to claim 4, it is characterized in that:Step S3 specific implementation Process is:
Whether succeeded using try-catch structure detections element operation;
If so, pass directly in next step;
If it is not, the process that then cyclic elements operates, until detection elements operate successfully, goes in next step.
6. a kind of system of Webpage element operation, it is characterized in that:Including
Element acquisition module, the mode waited using display waits element to occur, and waits elementary state to be changed into operable;
Element operation module, element is operated using testing tool;
Element processing module, whether succeed for detection elements operation, if not successfully, persistently carrying out element operation until element is grasped Succeed;
Encapsulation process module, for element acquisition module, element operation module and element processing module to be encapsulated into test case In.
7. a kind of system of Webpage element operation according to claim 6, it is characterized in that:The system also includes net Page acquisition module, change of the webpage acquisition module by detecting dom attributes judge dom load condition, wait dom loadings Finish.
CN201710865700.0A 2017-09-22 2017-09-22 A kind of method and system of Webpage element operation Pending CN107678952A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710865700.0A CN107678952A (en) 2017-09-22 2017-09-22 A kind of method and system of Webpage element operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710865700.0A CN107678952A (en) 2017-09-22 2017-09-22 A kind of method and system of Webpage element operation

Publications (1)

Publication Number Publication Date
CN107678952A true CN107678952A (en) 2018-02-09

Family

ID=61137093

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710865700.0A Pending CN107678952A (en) 2017-09-22 2017-09-22 A kind of method and system of Webpage element operation

Country Status (1)

Country Link
CN (1) CN107678952A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109857649A (en) * 2019-01-14 2019-06-07 珠海金山网络游戏科技有限公司 A kind of resource testing method and system
CN110399077A (en) * 2019-07-25 2019-11-01 北京明略软件系统有限公司 Element processing method and processing device, storage medium, electronic device
CN110413476A (en) * 2019-06-20 2019-11-05 平安普惠企业管理有限公司 Webpage collapses monitor method, device, computer equipment and storage medium
CN111831551A (en) * 2020-06-05 2020-10-27 厦门亿联网络技术股份有限公司 Non-blocking embedded software testing method, device and storage medium
CN112559066A (en) * 2020-12-08 2021-03-26 北京航天云路有限公司 Intelligent wait for page element load operation page element
CN113791974A (en) * 2021-08-25 2021-12-14 微梦创科网络科技(中国)有限公司 User interface UI element explicit waiting method and device
US11443241B2 (en) 2020-03-26 2022-09-13 Wipro Limited Method and system for automating repetitive task on user interface

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103984629A (en) * 2014-05-26 2014-08-13 上海斐讯数据通信技术有限公司 Method and system for achieving webpage automated testing through TCL (tool command language)
US20160011992A1 (en) * 2014-07-14 2016-01-14 Oracle International Corporation Variable handles
CN106776343A (en) * 2017-01-13 2017-05-31 中国科学院软件研究所 A kind of web application automated test tool and method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103984629A (en) * 2014-05-26 2014-08-13 上海斐讯数据通信技术有限公司 Method and system for achieving webpage automated testing through TCL (tool command language)
US20160011992A1 (en) * 2014-07-14 2016-01-14 Oracle International Corporation Variable handles
CN106776343A (en) * 2017-01-13 2017-05-31 中国科学院软件研究所 A kind of web application automated test tool and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张添: "基于Selenium的Web自动化测试", 《中国优秀硕士学位论文全文数据库》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109857649A (en) * 2019-01-14 2019-06-07 珠海金山网络游戏科技有限公司 A kind of resource testing method and system
CN109857649B (en) * 2019-01-14 2022-07-26 珠海金山网络游戏科技有限公司 Resource testing method and system
CN110413476A (en) * 2019-06-20 2019-11-05 平安普惠企业管理有限公司 Webpage collapses monitor method, device, computer equipment and storage medium
CN110399077A (en) * 2019-07-25 2019-11-01 北京明略软件系统有限公司 Element processing method and processing device, storage medium, electronic device
US11443241B2 (en) 2020-03-26 2022-09-13 Wipro Limited Method and system for automating repetitive task on user interface
CN111831551A (en) * 2020-06-05 2020-10-27 厦门亿联网络技术股份有限公司 Non-blocking embedded software testing method, device and storage medium
CN111831551B (en) * 2020-06-05 2022-05-17 厦门亿联网络技术股份有限公司 Non-blocking embedded software testing method, device and storage medium
CN112559066A (en) * 2020-12-08 2021-03-26 北京航天云路有限公司 Intelligent wait for page element load operation page element
CN113791974A (en) * 2021-08-25 2021-12-14 微梦创科网络科技(中国)有限公司 User interface UI element explicit waiting method and device

Similar Documents

Publication Publication Date Title
CN107678952A (en) A kind of method and system of Webpage element operation
CN107577607B (en) User interface automatic testing method and device, electronic equipment and storage medium
US8645912B2 (en) System and method for use in replaying software application events
US7076713B1 (en) Test generator for converting a model of computer component object behavior and stimulus values to test script
CN110716870B (en) Automatic service testing method and device
CN102981954B (en) The compatibility test method and electronic installation of a kind of input method
US8789020B2 (en) Interactive debugging environments and methods of providing the same
WO2008012172A1 (en) Automatic globalization verification testing for user interfaces
CN106294152A (en) The traversal test device and method of application user interface
EP3488348A1 (en) Visual regression testing tool
CN103049371A (en) Testing method and testing device of Android application programs
JP5451034B2 (en) Test plan table creation device and program thereof
CN108153667B (en) Automatic test method, device and system
CN110908915B (en) Test coverage rate display method and device and computer system
CN107957939B (en) Webpage interaction interface testing method and system
US10083108B1 (en) Automated stack-based computerized application crawler
US6427233B1 (en) Method for addressing the dynamic windows
US20140281719A1 (en) Explaining excluding a test from a test suite
Wang et al. Build an auto testing framework based on selenium and fitnesse
CN115934559A (en) Testing method of intelligent form testing system
CN103377122A (en) Quick test professional (QTP) device and method
CN113377650B (en) Automatic test case operation method and device, test equipment and storage medium
JP5022041B2 (en) Failure analysis apparatus, failure analysis method, and failure analysis program
Tao et al. An Approach to Mobile Application Testing Based on Natural Language Scripting.
CN104866413B (en) The method and device of multi-process 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180209