CN106569945B - Color system and method are distinguished in a kind of automation for ui testing - Google Patents

Color system and method are distinguished in a kind of automation for ui testing Download PDF

Info

Publication number
CN106569945B
CN106569945B CN201610910506.5A CN201610910506A CN106569945B CN 106569945 B CN106569945 B CN 106569945B CN 201610910506 A CN201610910506 A CN 201610910506A CN 106569945 B CN106569945 B CN 106569945B
Authority
CN
China
Prior art keywords
control
color
value
attribute
property
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610910506.5A
Other languages
Chinese (zh)
Other versions
CN106569945A (en
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.)
Huzhou YingLie Intellectual Property Operation Co.,Ltd.
Original Assignee
Shanghai Feixun Data Communication 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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201610910506.5A priority Critical patent/CN106569945B/en
Publication of CN106569945A publication Critical patent/CN106569945A/en
Application granted granted Critical
Publication of CN106569945B publication Critical patent/CN106569945B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

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)
  • Spectrometry And Color Measurement (AREA)
  • Testing, Inspecting, Measuring Of Stereoscopic Televisions And Televisions (AREA)

Abstract

The present invention provides a kind of automation for ui testing and distinguishes that colour system is united, including control color reflective module, for obtaining control color standard value from source code using reflection mechanism;Number distinguishes color module, for comparing the color value and control color standard value of running control.The present invention from Code Design program by using JAVA reflection mechanism, precisely being reflected when making script, to obtain the color attribute of the control in script, digitized of going forward side by side;As a result, at runtime, it is compared using digitized control color standard value with running control information, can find whether the color of running control is correct.It is reflected by source code and obtains control color value, error is not present;It is compared, is can be improved to specific efficiency by digitlization.

Description

Color system and method are distinguished in a kind of automation for ui testing
Technical field
The present invention relates to ui testing fields, and in particular to a kind of automation for ui testing is distinguished Color system and method.
Background technique
Current Android system version updating is getting faster, and version function interface also becomes increasingly complex, and is had many tiny The color of control and element can not distinguish, manually distinguish that colour efficiency is low by traditional, and be unable to judge accurately.
In existing Android system automatic test, by screenshot capture, picture color comparison is carried out.By Android system When operation, the point needed carries out screenshot capture and the comparison of original Target Photo.The method has certain error, and efficiency It is lower.
Summary of the invention
The purpose of the present invention is to provide a kind of automations for ui testing to distinguish color system and method to improve Have the defects that error and inefficiency in existing picture control methods.
The embodiment of the present invention provides a kind of automation for ui testing and distinguishes that colour system is united, comprising:
Control color reflective module, for obtaining control color standard value from source code using reflection mechanism;
Number distinguishes color module, for compare running control color value and the control color standard value.
Preferably, the control color reflective module includes:
Control color attribute adding unit, is added to the control property of acquisition for the control color attribute by control to be measured In;
Control property reflector element is obtained described to be measured for being reflected the control property using the reflection mechanism The color attribute value of control;
Attribute lead-out unit, for digitizing to obtain the control color standard value for the color attribute value, and by institute It states after control color standard value is aggregated into control property recording documents and exports.
Preferably, the control color attribute adding unit includes:
Control property obtains subelement, for obtaining the control category by the encapsulation class of Android automated test tool Property;
Control property imports subelement, for the incoming required control color attribute obtained, and imports and inherits institute State encapsulation class;
It is associated with subelement, for being associated with the control color attribute and the encapsulation class.
Preferably, the control property reflector element includes:
Root node locator unit, for positioning the control to be measured using the localization method from the encapsulation Similar integral Root node;
Subelement is reflected, for reflecting the root node using the reflection mechanism, finds the described of the control to be measured Color attribute value.
Preferably, when the color value of running control and the control color standard value difference, script is prompted Run-time error.
The embodiment of the present invention also provides a kind of automation for ui testing and distinguishes color method, comprising:
Control color standard value is obtained from source code using reflection mechanism;And
Compare running control color value and the control color standard value
Preferably, the step of control color standard value is obtained from source code using reflection mechanism when making script Suddenly include:
The control color attribute of control to be measured is added in the control property of acquisition;
The control property is reflected using the reflection mechanism to obtain the color attribute value of the control to be measured;And
The color attribute value is digitized to obtain the control color standard value, and the control color standard value is converged It is total to exporting after control property recording documents.
Preferably, the control color attribute of control to be measured is added to the step in the control property of acquisition includes:
The control property is obtained by the encapsulation class of Android automated test tool;
The control color attribute obtained required for incoming, and import and inherit the encapsulation class;And
It is associated with the control color attribute and the encapsulation class.
Preferably, the control property is reflected using the reflection mechanism to obtain the color attribute of the control to be measured The step of value includes:
The root node of the control to be measured is positioned using the localization method from the encapsulation Similar integral;And
The root node is reflected using the reflection mechanism, finds the color attribute value of the control to be measured.
Preferably, when the color value of running control and the control color standard value difference, script is prompted Run-time error.
Color system and method are distinguished in the automation for ui testing provided through the invention, when making script, Using JAVA reflection mechanism, precisely reflected from Code Design program, to obtain the color attribute of the control in script, and It is digitized;As a result, at runtime, compared using digitized control color standard value with running control information It is right, can find whether the color of running control is correct.It is reflected by source code and obtains control color value, there is no miss Difference;It is compared, is can be improved to specific efficiency by digitlization.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is the schematic diagram that colour system system is distinguished in the automation for ui testing that first embodiment of the invention provides.
Fig. 2 is the schematic diagram that colour system system is distinguished in the automation for ui testing that second embodiment of the invention provides.
Fig. 3 is the process signal that color method is distinguished in the automation for ui testing that third embodiment of the invention provides Figure.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
Embodiment one
Fig. 1 is the schematic diagram that colour system system is distinguished in the automation for ui testing that first embodiment of the invention provides. As shown in Figure 1, the automation for ui testing distinguishes that colour system system includes that control color reflective module 10 and number distinguish color mould Block 20.Wherein, the control color reflective module 10 is used to obtain control color standard from source code using reflection mechanism Value;The digital color distinguish color module 20 for compare running control color value and the control color standard value.Tool Body obtains using JAVA reflection mechanism the control color standard value of the control in script when making script;At runtime The control color standard value and running control information are compared, if the running control information and the control face Colour standard value is different, then prompts script run-time error.
JAVA reflection mechanism is, for any one class, can to know all properties of this class in operating status And method;For any one object, its any one method and attribute can be called;The information of this dynamic acquisition with And the function of the method for dynamic call object is known as the reflection mechanism of java language.
The automation for ui testing provided through this embodiment distinguishes that colour system is united, and when making script, utilizes JAVA reflection mechanism is precisely reflected from Code Design program, with the color attribute of the control in script, and carries out number Change, obtains control color standard value;At runtime, using digitized control color standard value and running control information into Row compares, and can find whether the color of running control is correct.It is reflected by source code and obtains control color value, be not present Error;It is compared, is can be improved to specific efficiency by digitlization.
Embodiment two
Fig. 2 is the schematic diagram that colour system system is distinguished in the automation for ui testing that second embodiment of the invention provides.
As shown in Fig. 2, the automation for ui testing distinguishes that colour system system includes for utilizing reflection mechanism from source generation Code in come obtain control color standard value control color reflective module 10 and the color value for comparing running control and The number of the control color standard value distinguishes color module 20.
Specifically, in the present embodiment, control color reflective module 10 includes:
Control color attribute adding unit 11, for the control color attribute of control to be measured to be added to the control category of acquisition In property;
Control property reflector element 12, obtained for reflecting the control property using the reflection mechanism it is described to The color attribute value of observing and controlling part;
Attribute lead-out unit 13 obtains the control color standard value for digitizing the color attribute value, and will The control color standard value exports after being aggregated into control property recording documents.
In android exploitation, it is added various controls in the interface Activity layout, such as Button, ImageView etc., each control can have each attribute, coordinate position, include class name, font content, color attribute etc.. We here seek to add a color category in the attribute obtained by Android automated test tool uiautomator Property.
Therefore, in the present embodiment, the control color attribute adding unit 11 includes:
Control property obtains subelement 111, for obtaining the control by the encapsulation class of Android automated test tool Attribute;
Specifically, by the encapsulation class of uiautomator carry out obtain control attribute, however obtain these attributes In, have no control color (Activity Color) this attribute.
Control property imports subelement 112, for the incoming required control color attribute obtained, and imports succession The encapsulation class;
Specifically, after choosing some Activity control, the control property of acquisition required for being passed to BackgroundColor, and the encapsulation class of the uiautomator in SDK is imported, and inherit such.
It is associated with subelement 113, for being associated with the control color attribute and the encapsulation class;
Specifically, the control color attribute and the encapsulation class are associated with using UiObject class.UiObject class is A parent (containing the class of all android control informations) of uiautomator, by BackgroundColor attribute After importing, control color attribute and uiautomator encapsulation class are connected using UiObject class.
Further, in the present embodiment, the control property reflector element 12 includes:
Root node locator unit 121, for utilizing the root node for positioning the control to be measured from the localization method;
Specifically, it is associated with by previous step, is come from the QueryController of the encapsulation Similar integral of uiautomator AccessibilityNodeInfo method is obtained, which can be positioned by AccessibilityNodeInfo method, obtained The root node of control is specified to user.
Subelement 122 is reflected, for reflecting the root node using the reflection mechanism, finds the institute of the control to be measured State color attribute value.
Specifically, with from uiautomator obtain inherit come QueryController obtain AccessibilityNodeInfo root node object finds out user by reflecting AccessibilityNodeInfo root node The color attribute of required control.
Further, after the color attribute value of the control needed for finding user, attribute lead-out unit 13 is digitized, Then (documents of all control properties of uiautomator interface record) are aggregated into window_dump.xml file.? In android system, each page can all generate a window_dump.xml attribute, and it is all to record the current interface UI Control property.Summarized by previous, has the color attribute value of control in window_dump.xml file, in this way, running When, the control color standard value of needs can be directly acquired by control property recording documents.
Further, the color attribute of control has been recorded, has been obtained when making script by control color reflective module 10 To digitized control color standard value (for example, 0*FFFF00);At runtime, number distinguishes that color module 20 can be according to control face Whether colour standard value goes comparison identical with running color, prompts to generate if different abnormal.
Advantageously, the automation for ui testing provided through this embodiment distinguishes that colour system is united, in production script When, it using JAVA reflection mechanism, is precisely reflected from Code Design program, to obtain the color category of the control in script Property, digitized of going forward side by side;As a result, at runtime, using digitized control color standard value and running control information into Row compares, and can find whether the color of running control is correct.It is reflected by source code and obtains control color value, be not present Error;It is compared, is can be improved to specific efficiency by digitlization.
Embodiment three
Fig. 3 is the process signal that color method is distinguished in the automation for ui testing that third embodiment of the invention provides Figure.As shown in figure 3, for ui testing automation distinguish color method the following steps are included:
Step S1: control color standard value is obtained from source code using reflection mechanism;
Specifically, in the present embodiment, step S1 includes following sub-step:
Step S11: the control color attribute of control to be measured is added in the control property of acquisition;
Step S12: the control property is reflected using the reflection mechanism to obtain the color category of the control to be measured Property value;And
Step S13: digitizing to obtain the control color standard value for the color attribute value, and by the control color Standard value exports after being aggregated into control property recording documents.
Further, step S11 includes following sub-step:
Step S111: the control property is obtained by the encapsulation class of Android automated test tool;
Step S112: the control color attribute obtained required for incoming, and import and inherit the encapsulation class;And
Step S113: the control color attribute and the encapsulation class are associated with.
Further, step S12 includes following sub-step:
Step S121: the root node that the control to be measured is positioned from the localization method of the encapsulation Similar integral is utilized;And
Step S122: the root node is reflected using the reflection mechanism, finds the color category of the control to be measured Property value.
Step S2: compare running control color value and the control color standard value.
Further, when the color value of running control and the control color standard value difference, foot is prompted This run-time error.
Specifically, in the present embodiment, after choosing some Activity control, the control category of acquisition required for being passed to Property BackgroundColor, and import the encapsulation class of the uiautomator in SDK, and inherit such;By BackgroundColor After attribute imports, control color attribute and uiautomator encapsulation class are connected using UiObject class;Pass through previous step Rapid association can obtain inheriting the AccessibilityNodeInfo method of coming from uiautomator, can obtain the specified control of user The root node of part (control can be positioned by it);With from uiautomator obtain inherit come QueryController obtain AccessibilityNodeInfo root node object finds out user by reflecting AccessibilityNodeInfo root node The color attribute of required control;It after the color attribute value of the control needed for finding user, is digitized, is then aggregated into In window_dump.xml file;Summarized by previous, has the color attribute of control in window_dump.xml file Value, in this way, at runtime, the control color standard value of needs can be directly acquired by control property recording documents.
Advantageously, color method is distinguished in the automation for ui testing provided through this embodiment, in production script When, it using JAVA reflection mechanism, is precisely reflected from Code Design program, to obtain the color category of the control in script Property, digitized of going forward side by side;As a result, at runtime, using digitized control color standard value and running control information into Row compares, and can find whether the color of running control is correct.It is reflected by source code and obtains control color value, be not present Error;It is compared, is can be improved to specific efficiency by digitlization.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention Made any modifications, equivalent replacements, and improvements etc., should all be included in the protection scope of the present invention within mind and principle.

Claims (6)

1. a kind of automation for ui testing distinguishes that colour system is united characterized by comprising
Control color reflective module, for obtaining control color standard value from source code using reflection mechanism, comprising: control Color attribute adding unit, for the control color attribute of control to be measured to be added in the control property of acquisition;Control property Reflector element obtains the color attribute of the control to be measured for reflecting the control property using the reflection mechanism Value;Attribute lead-out unit, for digitizing to obtain the control color standard value for the color attribute value, and by the control Color standard value exports after being aggregated into control property recording documents;
Number distinguishes color module, for compare running control color value and the control color standard value;
The control color attribute adding unit includes: that control property obtains subelement, for passing through Android automatic test work The encapsulation class of tool obtains the control property;Control property imports subelement, for the incoming required control face obtained Color attribute, and import and inherit the encapsulation class;It is associated with subelement, for being associated with the control color attribute and the encapsulation class.
2. distinguishing that colour system is united for the automation of ui testing as described in claim 1, which is characterized in that the control category Sexual reflex unit includes:
Root node locator unit, for positioning the root of the control to be measured using the localization method from the encapsulation Similar integral Node;
Subelement is reflected, for reflecting the root node using the reflection mechanism, finds the color of the control to be measured Attribute value.
3. distinguishing that colour system is united for the automation of ui testing as described in claim 1, which is characterized in that when running When the color value of control and the control color standard value difference, script run-time error is prompted.
4. color method is distinguished in a kind of automation for ui testing characterized by comprising
Control color standard value is obtained from source code using reflection mechanism, comprising: by the control color attribute of control to be measured It is added in the control property of acquisition;The control property is reflected using the reflection mechanism to obtain the control to be measured Color attribute value;And the color attribute value is digitized to obtain the control color standard value, and by the control color Standard value exports after being aggregated into control property recording documents;And
Compare running control color value and the control color standard value;
It is described that the control color attribute of control to be measured is added to the step in the control property of acquisition includes: automatic by Android The encapsulation class for changing testing tool obtains the control property;The control color attribute obtained required for incoming, and import after Hold the encapsulation class;And it is associated with the control color attribute and the encapsulation class.
5. distinguishing color method for the automation of ui testing as claimed in claim 4, which is characterized in that utilize described anti- Mechanism is penetrated to reflect the control property to obtain the step of the color attribute value of the control to be measured and include:
The root node of the control to be measured is positioned using the localization method from the encapsulation Similar integral;And
The root node is reflected using the reflection mechanism, finds the color attribute value of the control to be measured.
6. distinguishing color method for the automation of ui testing as claimed in claim 4, which is characterized in that when running When the color value of control and the control color standard value difference, script run-time error is prompted.
CN201610910506.5A 2016-10-19 2016-10-19 Color system and method are distinguished in a kind of automation for ui testing Active CN106569945B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610910506.5A CN106569945B (en) 2016-10-19 2016-10-19 Color system and method are distinguished in a kind of automation for ui testing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610910506.5A CN106569945B (en) 2016-10-19 2016-10-19 Color system and method are distinguished in a kind of automation for ui testing

Publications (2)

Publication Number Publication Date
CN106569945A CN106569945A (en) 2017-04-19
CN106569945B true CN106569945B (en) 2019-10-25

Family

ID=58533976

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610910506.5A Active CN106569945B (en) 2016-10-19 2016-10-19 Color system and method are distinguished in a kind of automation for ui testing

Country Status (1)

Country Link
CN (1) CN106569945B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109783351A (en) * 2018-12-13 2019-05-21 重庆金融资产交易所有限责任公司 Interface detection method, apparatus and computer readable storage medium
CN110309073B (en) * 2019-06-28 2021-07-27 上海交通大学 Method, system and terminal for automatically detecting user interface errors of mobile application program
CN114968466A (en) * 2022-07-14 2022-08-30 深圳市明源云空间电子商务有限公司 Page color matching adjustment method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064782A (en) * 2011-10-21 2013-04-24 腾讯科技(深圳)有限公司 Method and device for obtaining control
CN104516633A (en) * 2014-11-19 2015-04-15 微梦创科网络科技(中国)有限公司 User interface element management method and device
CN104809053A (en) * 2014-01-23 2015-07-29 阿里巴巴集团控股有限公司 Control style testing method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8375313B2 (en) * 2010-06-01 2013-02-12 Oracle International Corporation User interface generation with scoring
US8938683B2 (en) * 2012-09-11 2015-01-20 Ebay Inc. Visual state comparator

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064782A (en) * 2011-10-21 2013-04-24 腾讯科技(深圳)有限公司 Method and device for obtaining control
CN104809053A (en) * 2014-01-23 2015-07-29 阿里巴巴集团控股有限公司 Control style testing method and device
CN104516633A (en) * 2014-11-19 2015-04-15 微梦创科网络科技(中国)有限公司 User interface element management method and device

Also Published As

Publication number Publication date
CN106569945A (en) 2017-04-19

Similar Documents

Publication Publication Date Title
US11163851B2 (en) Method, apparatus, computer device and storage medium of page displaying
CN106569945B (en) Color system and method are distinguished in a kind of automation for ui testing
WO2019085084A1 (en) Buried point processing method and apparatus, computer device, and storage medium
CN104391797A (en) GUI (graphical user interface) widget identification method and device
CN112306855B (en) Interface automation test method, device, terminal and storage medium
KR20160064930A (en) Alarm classification method in finding potential bug in a source code, computer program for the same, recording medium storing computer program for the same
KR20060093004A (en) Baseline architecture monitor application for distributed systems
US20190065465A1 (en) Chatbot version comparison
CN109117368A (en) A kind of interface test method, electronic equipment and storage medium
CN113050953A (en) Method, device and storage medium for generating code based on annotation
CN110659197B (en) Application test case generation method and device and software test system
US11422917B2 (en) Deriving software application dependency trees for white-box testing
CN103955372B (en) Method and device for detecting resources in mobile terminal
US8261239B2 (en) Locating a testable object in a functional testing tool
US10846206B2 (en) Adaptive software testing
CN108763092B (en) Code defect detection method and device based on cross validation
CN111967137A (en) Semiconductor equipment modeling method and device
CN111611176A (en) Automatic generation method, system and medium for universal interface coverage rate model verification environment
CN115794638A (en) Test method, system and computer equipment based on code change analysis engine
CN112559368A (en) Interface automation test method and its use case generation method, equipment and storage medium
CN112784540B (en) Document number checking method and device
CN113886221A (en) Test script generation method and device, storage medium and electronic equipment
CN102708055A (en) Method and device for testing credibility of software
CN117873907B (en) Control element testing method and device and storage medium
CN116880826B (en) Visualized code generation method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20201125

Address after: Room 10242, No. 260, Jiangshu Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Hangzhou Jiji Intellectual Property Operation Co., Ltd

Address before: 201616 Shanghai city Songjiang District Sixian Road No. 3666

Patentee before: Phicomm (Shanghai) Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20201216

Address after: 8319 Yanshan Road, Bengbu City, Anhui Province

Patentee after: Bengbu Lichao Information Technology Co.,Ltd.

Address before: Room 10242, No. 260, Jiangshu Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee before: Hangzhou Jiji Intellectual Property Operation Co., Ltd

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210308

Address after: 313000 room 1019, Xintiandi commercial office, Yishan street, Wuxing District, Huzhou, Zhejiang, China

Patentee after: Huzhou YingLie Intellectual Property Operation Co.,Ltd.

Address before: 8319 Yanshan Road, Bengbu City, Anhui Province

Patentee before: Bengbu Lichao Information Technology Co.,Ltd.