CN111045913A - Method and terminal for automatically logging in to-be-tested application - Google Patents

Method and terminal for automatically logging in to-be-tested application Download PDF

Info

Publication number
CN111045913A
CN111045913A CN201811182408.XA CN201811182408A CN111045913A CN 111045913 A CN111045913 A CN 111045913A CN 201811182408 A CN201811182408 A CN 201811182408A CN 111045913 A CN111045913 A CN 111045913A
Authority
CN
China
Prior art keywords
tested
application
preset
interface
login
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.)
Granted
Application number
CN201811182408.XA
Other languages
Chinese (zh)
Other versions
CN111045913B (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.)
Fujian Tianquan Educational Technology Ltd
Original Assignee
Fujian Tianquan Educational Technology 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 Fujian Tianquan Educational Technology Ltd filed Critical Fujian Tianquan Educational Technology Ltd
Priority to CN201811182408.XA priority Critical patent/CN111045913B/en
Publication of CN111045913A publication Critical patent/CN111045913A/en
Application granted granted Critical
Publication of CN111045913B publication Critical patent/CN111045913B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Human Computer Interaction (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a terminal for automatically logging in an application to be tested, which judge whether to start automatic login setting or not by receiving the application to be tested, judge whether preset login information corresponding to the application to be tested exists or not if the automatic login setting is started, acquire interface information after the application to be tested is started if the preset login information exists, judge whether the interface after the application to be tested is a login interface or not, automatically input the preset login information into a text box of the login interface if the preset login information exists, automatically log in the application to be tested, reduce the manual burden, improve the working efficiency, and can be used in various automatic tests such as random test, script test and the like, and the reusability is strong.

Description

Method and terminal for automatically logging in to-be-tested application
Technical Field
The invention relates to the technical field of software testing, in particular to a method and a terminal for automatically logging in an application to be tested.
Background
The automatic random test is a random combination simulation of operations such as clicking, double clicking, long pressing, up-down sliding, left-right sliding, shaking, volume adjustment, screen locking, screen unlocking, transverse/longitudinal rotation, simultaneous clicking of two hands, button clicking, zooming in and out and the like on the application to be tested. If an application needing to be logged in is randomly tested, the application is located in a login interface after the application is opened, at the moment, if the random test is carried out, the login interface is randomly tested, but the automatic random test is carried out aiming at a specific service interface after the application is logged in, so that manual login is needed, the automatic random test is initiated, and when the number of applications to be tested is large, large manpower is needed to be invested to log in continuously, and time is wasted and boring.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: a method and a terminal for automatically logging in an application to be tested can automatically log in the application to be tested and reduce the manual burden.
In order to solve the technical problems, the invention adopts the technical scheme that:
a method for automatically logging in an application to be tested comprises the following steps:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
and S4, automatically inputting the preset login information into a text box of the login interface.
In order to solve the technical problems, the invention adopts the technical scheme that:
a terminal for automatically logging in an application to be tested comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor executes the computer program to realize the following steps:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
and S4, automatically inputting the preset login information into a text box of the login interface.
The invention has the beneficial effects that: through receiving the application to be tested, whether automatic login setting is started is judged, if so, whether preset login information corresponding to the application to be tested exists is judged, if so, information of an interface after the application to be tested is started is acquired, whether the interface after the application to be tested is started is a login interface is judged, if so, the preset login information is automatically input into a text box of the login interface, the application to be tested can be automatically logged in, manual burden is reduced, working efficiency is improved, the automatic login method can be used in various automatic tests such as random test and script test, and reusability is strong.
Drawings
Fig. 1 is a flowchart of a method for automatically logging in an application to be tested according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a terminal for automatically logging in an application to be tested according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for automatically logging in an application under test according to an embodiment of the present invention;
description of reference numerals:
1. a terminal for automatically logging in an application to be tested; 2. A memory; 3. A processor.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key concept of the invention is that after the automatic login setting is started, if the preset login information corresponding to the application to be tested exists, the information of the interface after the application to be tested is started is obtained and whether the interface is the login interface is judged, if so, the preset login information is automatically input into a text box of the login interface.
Referring to fig. 1, a method for automatically logging in an application to be tested includes the steps of:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
and S4, automatically inputting the preset login information into a text box of the login interface.
From the above description, the beneficial effects of the present invention are: through receiving the application to be tested, whether automatic login setting is started is judged, if so, whether preset login information corresponding to the application to be tested exists is judged, if so, information of an interface after the application to be tested is started is acquired, whether the interface after the application to be tested is started is a login interface is judged, if so, the preset login information is automatically input into a text box of the login interface, the application to be tested can be automatically logged in, manual burden is reduced, working efficiency is improved, the automatic login method can be used in various automatic tests such as random test and script test, and reusability is strong.
Further, the step S2 of determining whether there is preset login information corresponding to the application to be tested specifically includes:
acquiring the name of the package of the application to be tested;
and inquiring whether preset login information corresponding to the application to be tested exists according to the name of the package of the application to be tested.
According to the description, the corresponding preset login information is inquired according to the name of the package of the application to be tested, the one-to-one correspondence relationship between the application to be tested and the preset login information is established, and the acquisition of the corresponding preset login information is facilitated.
Further, the obtaining information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is started is a login interface in step S3 includes:
s31, exporting the information of the interface after the application to be tested is started into a first file according to a first format;
s32, traversing the first file, finding the package attribute of the first file, judging whether the package attribute in the first file is equal to the package attribute of the application to be tested, if so, starting the application to be tested, acquiring information of an interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface; if not, restarting the application to be tested, and returning to execute the step S31.
According to the description, the package attribute in the information of the interface after the application to be tested is started is compared with the package attribute of the application to be tested, whether the application to be tested is started or not is judged, the accuracy in the automatic login process is improved, and the preset login information is used for the corresponding application to be tested.
Further, the obtaining information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is started is a login interface in step S32 includes:
parsing the first file while traversing the first file:
s321, judging whether a preset first field appears, if so, adding one to a value of a preset statistical parameter, wherein the preset statistical parameter is used for counting the number of times of appearance of the preset first field;
s322, judging whether a preset second field appears for the first time after the preset first field, if so, acquiring a first character sequence after the preset second field, and executing a step S323; if not, go down and return to step S321;
s323, judging whether the first character sequence comprises a preset second character sequence, if so, giving the value of the preset statistical parameter recorded at present to a user-defined parameter corresponding to the preset first field;
s324, judging whether the value of the preset statistical parameter is equal to a first preset value or not and whether the values of the self-defined parameters corresponding to the preset first field are not all empty or not, if yes, executing a step S325; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
and S325, judging whether a preset third field exists, if so, executing a step S4, and if not, ending the automatic login.
According to the description, in the process of analyzing the first file, whether the interface is the login interface after the application to be tested is started is judged, so that the next operation is ensured under the login interface, the accuracy is improved, meanwhile, the position of the text box corresponding to the preset login information is confirmed, and the subsequent automatic login operation is facilitated.
Further, the step S4 includes:
the preset login information comprises first information and second information;
automatically inputting second information of preset login information into a text box corresponding to the preset first field corresponding to a self-defined parameter with a non-empty value by utilizing a UI technology;
and automatically inputting the first information of the preset login information into the remaining text boxes corresponding to the preset first fields by utilizing a UI technology.
According to the description, the preset login information is automatically input into the corresponding text boxes, so that the manual burden is reduced, and the working efficiency is improved.
Referring to fig. 2, a terminal for automatically logging in an application to be tested includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor executes the computer program to implement the following steps:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
and S4, automatically inputting the preset login information into a text box of the login interface.
From the above description, the beneficial effects of the present invention are: through receiving the application to be tested, whether automatic login setting is started is judged, if so, whether preset login information corresponding to the application to be tested exists is judged, if so, information of an interface after the application to be tested is started is acquired, whether the interface after the application to be tested is started is a login interface is judged, if so, the preset login information is automatically input into a text box of the login interface, the application to be tested can be automatically logged in, manual burden is reduced, working efficiency is improved, the automatic login method can be used in various automatic tests such as random test and script test, and reusability is strong.
Further, the step S2 of determining whether there is preset login information corresponding to the application to be tested specifically includes:
acquiring the name of the package of the application to be tested;
and inquiring whether preset login information corresponding to the application to be tested exists according to the name of the package of the application to be tested.
According to the description, the corresponding preset login information is inquired according to the name of the package of the application to be tested, the one-to-one correspondence relationship between the application to be tested and the preset login information is established, and the acquisition of the corresponding preset login information is facilitated.
Further, the obtaining information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is started is a login interface in step S3 includes:
s31, exporting the information of the interface after the application to be tested is started into a first file according to a first format;
s32, traversing the first file, finding the package attribute of the first file, judging whether the package attribute in the first file is equal to the package attribute of the application to be tested, if so, starting the application to be tested, acquiring information of an interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface; if not, restarting the application to be tested, and returning to execute the step S31.
According to the description, the package attribute in the information of the interface after the application to be tested is started is compared with the package attribute of the application to be tested, whether the application to be tested is started or not is judged, the accuracy in the automatic login process is improved, and the preset login information is used for the corresponding application to be tested.
Further, the obtaining information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is started is a login interface in step S32 includes:
parsing the first file while traversing the first file:
s321, judging whether a preset first field appears, if so, adding one to a value of a preset statistical parameter, wherein the preset statistical parameter is used for counting the number of times of appearance of the preset first field;
s322, judging whether a preset second field appears for the first time after the preset first field, if so, acquiring a first character sequence after the preset second field, and executing a step S323; if not, go down and return to step S321;
s323, judging whether the first character sequence comprises a preset second character sequence, if so, giving the value of the preset statistical parameter recorded at present to a user-defined parameter corresponding to the preset first field;
s324, judging whether the value of the preset statistical parameter is equal to a first preset value or not and whether the values of the self-defined parameters corresponding to the preset first field are not all empty or not, if yes, executing a step S325; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
and S325, judging whether a preset third field exists, if so, executing a step S4, and if not, ending the automatic login.
According to the description, in the process of analyzing the first file, whether the interface is the login interface after the application to be tested is started is judged, so that the next operation is ensured under the login interface, the accuracy is improved, meanwhile, the position of the text box corresponding to the preset login information is confirmed, and the subsequent automatic login operation is facilitated.
Further, the step S4 includes:
the preset login information comprises first information and second information;
automatically inputting second information of preset login information into a text box corresponding to the preset first field corresponding to a self-defined parameter with a non-empty value by utilizing a UI technology;
and automatically inputting the first information of the preset login information into the remaining text boxes corresponding to the preset first fields by utilizing a UI technology.
According to the description, the preset login information is automatically input into the corresponding text boxes, so that the manual burden is reduced, and the working efficiency is improved.
Example one
Referring to fig. 1 and fig. 3, a method for automatically logging in an application to be tested includes the steps of:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
the specific step of judging whether the preset login information corresponding to the application to be tested exists is as follows:
acquiring the name of the package of the application to be tested;
and inquiring whether preset login information corresponding to the application to be tested exists according to the name of the package of the application to be tested.
Specifically, the name of the package of the application to be tested is transmitted into a database to inquire whether preset login information corresponding to the application to be tested exists or not, wherein the preset login information comprises an account and a password, and if yes, the account and the password corresponding to the application to be tested are obtained; and if not, receiving the name of the package of the application to be tested, the account number and the password for logging in, and storing the package of the application to be tested, the account number and the password in a database.
Installing the application to be tested and starting the application to be tested;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
the obtaining information of the interface after the application to be tested is started and judging whether the interface after the application to be tested is a login interface or not comprises the following steps:
s31, exporting the information of the interface after the application to be tested is started into a first file according to a first format;
the first format is a hierarchical and XML format, and specifically, the interface after the application to be tested is started is exported as a first file to a specified target position according to the hierarchical and XML format.
S32, traversing the first file, finding the package attribute of the first file, judging whether the package attribute in the first file is equal to the package attribute of the application to be tested, if so, starting the application to be tested, acquiring information of an interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface; if not, restarting the application to be tested, and returning to execute the step S31.
The obtaining information of the interface after the application to be tested is started and judging whether the interface after the application to be tested is a login interface or not comprises the following steps:
parsing the first file while traversing the first file:
s321, judging whether a preset first field appears, if so, adding one to a value of a preset statistical parameter, wherein the preset statistical parameter is used for counting the number of times of appearance of the preset first field;
traversing and analyzing the first file from top to bottom; the preset first field is a textbox control; the login interface is usually an account box and a password box, so the value of the preset statistical parameter is usually two;
s322, judging whether a preset second field appears for the first time after the preset first field, if so, acquiring a first character sequence after the preset second field, and executing a step S323; if not, go down and return to step S321;
the second field is obtained by selecting a first field, wherein the second field is obtained by selecting a password, the second field is an attribute of the textbox control, and the first character sequence is a character sequence of 6 characters;
specifically, after the preset first field representing the text box is found each time, a second field with password appearing for the first time is searched for at a position behind the preset first field, and 6 characters after password are obtained as the first character sequence;
s323, judging whether the first character sequence comprises a preset second character sequence, if so, giving the value of the preset statistical parameter recorded at present to a user-defined parameter corresponding to the preset first field;
the second character sequence is true, and the name of the self-defined parameter is pwdEdit;
specifically, whether the second character sequence true is included in the first character sequence is judged, that is, whether the second field password contains true is judged, if yes, the attribute password of the textbox control is true, and the value of the preset statistical parameter recorded at present is given to a custom parameter pwdeedit corresponding to the preset first field;
the value of the custom parameter pwdEdit represents the position of the password box on the interface, namely the first text box from top to bottom on the interface;
s324, judging whether the value of the preset statistical parameter is equal to a first preset value or not and whether the values of the self-defined parameters corresponding to the preset first field are not all empty or not, if yes, executing a step S325; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
the first preset value is 2, and 2 text boxes are required to be represented; the values of the self-defined parameters are not all null, so that the text box comprises a password input box;
and S325, judging whether a preset third field exists, if so, executing a step S4, and if not, ending the automatic login.
Wherein the preset third field is "login";
specifically, whether a 'log-on' style field is contained or not is judged according to the regular expression, if yes, a login button is contained, and step S4 is executed; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
and S4, automatically inputting the preset login information into a text box of the login interface.
The preset login information comprises first information and second information, wherein the first information is an account, and the second information is a password;
specifically, a UI technology is utilized to enable second information of preset login information, namely a text box corresponding to the preset first field corresponding to the self-defined parameter with the password automatic input value not being empty;
automatically inputting first information of preset login information, namely the account number, into a remaining text box corresponding to the preset first field by using a UI technology;
and clicking the login button judged according to the regular expression by utilizing a UI technology to finish the simulation of manual automatic login and enter the next step of automatic test.
Example two
The method in the first embodiment is applied to a specific scene, and the method is implemented when the application to be tested is an Android application:
a developer selects tested equipment, which can be an Android mobile phone or an Android Pad;
s1, receiving the Android application to be tested, judging whether to start automatic login setting, and if so, executing a step S2;
the Android application to be tested is an application APP ending with an APK suffix;
s2, judging whether preset login information corresponding to the Android application to be tested exists or not, if so, acquiring the preset login information corresponding to the Android application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
the step of judging whether the preset login information corresponding to the Android application to be tested exists specifically is as follows:
acquiring the name of the package of the Android application to be tested;
and inquiring whether preset login information corresponding to the Android application to be tested exists according to the name of the package of the Android application to be tested.
Specifically, the name of the package of the Android application to be tested is transmitted into a database to inquire whether preset login information corresponding to the Android application to be tested exists or not, wherein the preset login information comprises an account and a password, and if yes, the account and the password corresponding to the Android application to be tested are obtained; if not, receiving the name of the package of the Android application to be tested, the account number and the password for logging in, and storing the package of the Android application to be tested, the account number and the password in a database.
Installing the tested Android application, and starting the tested Android application;
s3, obtaining information of the started interface of the Android application to be tested, judging whether the started interface of the Android application to be tested is a login interface, and if so, executing the step S4;
the obtaining of the information of the interface after the Android application to be tested is started and the judging whether the interface after the Android application to be tested is a login interface or not include:
s31, exporting the information of the interface after the Android application to be tested is started into a first file according to a first format;
wherein the first format is a hierarchical and XML format;
specifically, a uiautomator dump [ file ] command is executed, the interface after the Android application to be tested is started is exported to a specified target position as a first file according to the hierarchy and an XML format, for example, the uiautomator dump/sdcard/logic.xml command indicates that the exported target position is a root directory under an sd card of the Android device, and the file name of the exported first file is logic.xml;
s32, traversing the first file login.xml, finding the package attribute of the first file, judging whether the package attribute in the first file is equal to the package attribute of the Android application to be tested, if so, starting the Android application to be tested, acquiring information of an interface after the Android application to be tested is started, and judging whether the interface after the Android application to be tested is a login interface; and if not, restarting the Android application to be tested, and returning to execute the step S31.
The obtaining of the information of the interface after the Android application to be tested is started and the judging whether the interface after the Android application to be tested is a login interface or not include:
parsing the first file while traversing the first file:
s321, judging whether a preset first field appears, if so, adding one to a value of a preset statistical parameter, wherein the preset statistical parameter is used for counting the number of times of appearance of the preset first field;
traversing and analyzing the first file from top to bottom; the preset first field is a text box control android.widget.EditText; the login interface is usually an account box and a password box, so the value of the preset statistical parameter is usually two;
s322, judging whether a preset second field appears for the first time after the preset first field, if so, acquiring a first character sequence after the preset second field, and executing a step S323; if not, go down and return to step S321;
the second field is obtained by selecting a first field, wherein the second field is obtained by selecting a password, the second field is an attribute of the textbox control, and the first character sequence is a character sequence of 6 characters;
specifically, after the preset first field representing the text box is found each time, a second field with password appearing for the first time is searched for at a position behind the preset first field, and 6 characters after password are obtained as the first character sequence;
s323, judging whether the first character sequence comprises a preset second character sequence, if so, giving the value of the preset statistical parameter recorded at present to a user-defined parameter corresponding to the preset first field;
the second character sequence is true, and the name of the self-defined parameter is pwdEdit;
specifically, whether the second character sequence true is included in the first character sequence is judged, that is, whether the second field password contains true is judged, if yes, the attribute password of the textbox control is true, and the value of the preset statistical parameter recorded at present is given to a custom parameter pwdeedit corresponding to the preset first field;
the value of the custom parameter pwdEdit represents the position of the password box on the interface, namely the first text box from top to bottom on the interface;
for example, after the android.widget.edittext appears for the second time, a word eye with password is searched after the android.widget.edittext, and after the word eye is found, it is judged that the first character sequence "true" after password contains the second character sequence true, and then the value of the preset statistical parameter recorded at present is given to the custom parameter pwdredit corresponding to the preset first field, that is, pwdredit is 2, and the second android.widget.edittext text box representing the interface from top to bottom is a password box;
s324, judging whether the value of the preset statistical parameter is equal to a first preset value or not and whether the values of the self-defined parameters corresponding to the preset first field are not all empty or not, if yes, executing a step S325; if not, the interface is not a login interface after the Android application to be tested is started, and the automatic login is finished;
the first preset value is 2, and 2 text boxes are required to be represented; the values of the self-defined parameters are not all null, so that the text box comprises a password input box;
and S325, judging whether a preset third field exists, if so, executing a step S4, and if not, ending the automatic login.
Wherein the preset third field is "login";
specifically, whether a 'log-on' style field is contained or not is judged according to the regular expression, if yes, a login button is contained, and step S4 is executed; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
and S4, automatically inputting the preset login information into a text box of the login interface.
The preset login information comprises first information and second information, wherein the first information is an account, and the second information is a password;
specifically, a UI technology is utilized to enable second information of preset login information, namely a text box corresponding to the preset first field corresponding to the self-defined parameter with the password automatic input value not being empty;
automatically inputting first information of preset login information, namely the account number, into a remaining text box corresponding to the preset first field by using a UI technology;
for example, the custom parameter pwdredit is 2, which indicates that the second android.
And clicking the login button judged according to the regular expression by utilizing a UI technology to finish the simulation of manual automatic login and enter the next step of automatic test.
EXAMPLE III
Referring to fig. 2, a terminal 1 for automatically logging in an application to be tested includes a memory 2, a processor 3, and a computer program stored in the memory 2 and capable of running on the processor 3, where the processor 3 implements the steps in the first embodiment when executing the computer program.
In summary, according to the method and the terminal for automatically logging in the application to be tested provided by the present invention, whether an automatic login setting is started is determined by receiving the application to be tested, if yes, it is determined whether preset login information corresponding to the application to be tested exists, if yes, information of an interface after the application to be tested is started is obtained, it is determined whether the interface after the application to be tested is started is a login interface, if yes, the preset login information is automatically input into a text box of the login interface, so that the application to be tested can be automatically logged in, a manual burden is reduced, and a working efficiency is improved; the method has the advantages that the one-to-one corresponding relation between the application to be tested and the preset login information is established, the corresponding preset login information can be conveniently obtained, the interface is judged for many times after the application to be tested is started in a traversing and analyzing mode, the accuracy in the automatic login process is improved, the method can be used in various automatic tests such as random test and script test, and the reusability is high.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method for automatically logging in an application to be tested is characterized by comprising the following steps:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
and S4, automatically inputting the preset login information into a text box of the login interface.
2. The method according to claim 1, wherein the step S2 of determining whether the preset login information corresponding to the application to be tested exists specifically includes:
acquiring the name of the package of the application to be tested;
and inquiring whether preset login information corresponding to the application to be tested exists according to the name of the package of the application to be tested.
3. The method according to claim 1 or 2, wherein the step S3 of obtaining the information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is a login interface includes:
s31, exporting the information of the interface after the application to be tested is started into a first file according to a first format;
s32, traversing the first file, finding the package attribute of the first file, judging whether the package attribute in the first file is equal to the package attribute of the application to be tested, if so, starting the application to be tested, acquiring information of an interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface; if not, restarting the application to be tested, and returning to execute the step S31.
4. The method according to claim 3, wherein the step S32 of obtaining the information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is a login interface includes:
parsing the first file while traversing the first file:
s321, judging whether a preset first field appears, if so, adding one to a value of a preset statistical parameter, wherein the preset statistical parameter is used for counting the number of times of appearance of the preset first field;
s322, judging whether a preset second field appears for the first time after the preset first field, if so, acquiring a first character sequence after the preset second field, and executing a step S323; if not, go down and return to step S321;
s323, judging whether the first character sequence comprises a preset second character sequence, if so, giving the value of the preset statistical parameter recorded at present to a user-defined parameter corresponding to the preset first field;
s324, judging whether the value of the preset statistical parameter is equal to a first preset value or not and whether the values of the self-defined parameters corresponding to the preset first field are not all empty or not, if yes, executing a step S325; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
and S325, judging whether a preset third field exists, if so, executing a step S4, and if not, ending the automatic login.
5. The method according to claim 4, wherein the step S4 includes:
the preset login information comprises first information and second information;
automatically inputting second information of preset login information into a text box corresponding to the preset first field corresponding to a self-defined parameter with a non-empty value by utilizing a UI technology;
and automatically inputting the first information of the preset login information into the remaining text boxes corresponding to the preset first fields by utilizing a UI technology.
6. A terminal for automatically logging in an application to be tested comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, and is characterized in that the processor executes the computer program to realize the following steps:
s1, receiving the application to be tested, judging whether to start the automatic login setting, if so, executing a step S2;
s2, judging whether preset login information corresponding to the application to be tested exists or not, if so, acquiring the preset login information corresponding to the application to be tested, executing the step S3, and if not, receiving the preset login information and executing the step S3;
s3, acquiring information of the interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface or not, if so, executing a step S4;
and S4, automatically inputting the preset login information into a text box of the login interface.
7. The terminal for automatically logging in to an application to be tested according to claim 6, wherein the step S2 of determining whether the preset login information corresponding to the application to be tested exists specifically is to:
acquiring the name of the package of the application to be tested;
and inquiring whether preset login information corresponding to the application to be tested exists according to the name of the package of the application to be tested.
8. The terminal for automatically logging in an application to be tested according to claim 6 or 7, wherein the step S3 of obtaining the information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is a login interface includes:
s31, exporting the information of the interface after the application to be tested is started into a first file according to a first format;
s32, traversing the first file, finding the package attribute of the first file, judging whether the package attribute in the first file is equal to the package attribute of the application to be tested, if so, starting the application to be tested, acquiring information of an interface after the application to be tested is started, and judging whether the interface after the application to be tested is started is a login interface; if not, restarting the application to be tested, and returning to execute the step S31.
9. The terminal for automatically logging in an application to be tested according to claim 8, wherein the step S32 of obtaining the information of the interface after the application to be tested is started and determining whether the interface after the application to be tested is a login interface includes:
parsing the first file while traversing the first file:
s321, judging whether a preset first field appears, if so, adding one to a value of a preset statistical parameter, wherein the preset statistical parameter is used for counting the number of times of appearance of the preset first field;
s322, judging whether a preset second field appears for the first time after the preset first field, if so, acquiring a first character sequence after the preset second field, and executing a step S323; if not, go down and return to step S321;
s323, judging whether the first character sequence comprises a preset second character sequence, if so, giving the value of the preset statistical parameter recorded at present to a user-defined parameter corresponding to the preset first field;
s324, judging whether the value of the preset statistical parameter is equal to a first preset value or not and whether the values of the self-defined parameters corresponding to the preset first field are not all empty or not, if yes, executing a step S325; if not, the interface is not a login interface after the application to be tested is started, and the automatic login is finished;
and S325, judging whether a preset third field exists, if so, executing a step S4, and if not, ending the automatic login.
10. The terminal for automatically logging in an application under test according to claim 9, wherein the step S4 includes:
the preset login information comprises first information and second information;
automatically inputting second information of preset login information into a text box corresponding to the preset first field corresponding to a self-defined parameter with a non-empty value by utilizing a UI technology;
and automatically inputting the first information of the preset login information into the remaining text boxes corresponding to the preset first fields by utilizing a UI technology.
CN201811182408.XA 2018-10-11 2018-10-11 Method and terminal for automatically logging in application to be tested Active CN111045913B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811182408.XA CN111045913B (en) 2018-10-11 2018-10-11 Method and terminal for automatically logging in application to be tested

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811182408.XA CN111045913B (en) 2018-10-11 2018-10-11 Method and terminal for automatically logging in application to be tested

Publications (2)

Publication Number Publication Date
CN111045913A true CN111045913A (en) 2020-04-21
CN111045913B CN111045913B (en) 2023-07-07

Family

ID=70229029

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811182408.XA Active CN111045913B (en) 2018-10-11 2018-10-11 Method and terminal for automatically logging in application to be tested

Country Status (1)

Country Link
CN (1) CN111045913B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104683327A (en) * 2015-01-29 2015-06-03 中国科学院信息工程研究所 Method for detecting safety of user login interface of Android software
US20160337854A1 (en) * 2015-05-13 2016-11-17 Spotify Ab Automatic login on a website by means of an app
CN106790686A (en) * 2017-02-16 2017-05-31 上海斐讯数据通信技术有限公司 A kind of user name password fill method and system
CN106982226A (en) * 2017-04-27 2017-07-25 成都奇鲁科技有限公司 Automatic logging method and device
CN107402877A (en) * 2016-05-19 2017-11-28 福建天晴数码有限公司 APP method of testings and system based on Android ends

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104683327A (en) * 2015-01-29 2015-06-03 中国科学院信息工程研究所 Method for detecting safety of user login interface of Android software
US20160337854A1 (en) * 2015-05-13 2016-11-17 Spotify Ab Automatic login on a website by means of an app
CN107402877A (en) * 2016-05-19 2017-11-28 福建天晴数码有限公司 APP method of testings and system based on Android ends
CN106790686A (en) * 2017-02-16 2017-05-31 上海斐讯数据通信技术有限公司 A kind of user name password fill method and system
CN106982226A (en) * 2017-04-27 2017-07-25 成都奇鲁科技有限公司 Automatic logging method and device

Also Published As

Publication number Publication date
CN111045913B (en) 2023-07-07

Similar Documents

Publication Publication Date Title
CN107704395B (en) Cloud platform automation test implementation method and system based on Openstack
CN106021102B (en) The generation method and device of automatic test file
US8856747B2 (en) Enterprise JavaBeans explorer
US7661053B2 (en) Methods and apparatus for patternizing device responses
CN111596965A (en) Project engineering initialization method, device, computer equipment and storage medium
US10725893B2 (en) System and method for determination of code coverage for software applications in a network environment
CN110399299A (en) The execution method of automated test frame and test case
CN106021101B (en) The method and device that mobile terminal is tested
CN108874649B (en) Method and device for generating automatic test script and computer equipment thereof
CN114465937B (en) Network card testing method, device, server and medium
CN116302930A (en) Application testing method and device
CN112346946B (en) User software operation behavior monitoring method and system based on control positioning
CN111045913A (en) Method and terminal for automatically logging in to-be-tested application
CN113420189A (en) Intelligent terminal android App control method and system based on RPA
CN108932121B (en) Multi-tenant distributed service component research and development oriented module and method
CN116541005A (en) Abstract description method, device, equipment and medium for front-end interface configuration
CN108182120B (en) Interface calling method and system, storage medium and computer equipment
CN108304230B (en) Implementation method and device for adjusting application attribute and readable storage medium
CN110825649A (en) Application testing method, device, equipment and storage medium
CN109522217A (en) The internal storage testing method and terminal device of application program
CN112433651B (en) Region identification method, device, storage medium and device
CN114064327A (en) Baffle testing method, device, storage medium and program product
CN112463272A (en) Interface layout loading display method and system, electronic equipment and storage medium
CN112115064A (en) Method for automatically configuring performance scene based on performance test requirement
CN111061630A (en) Product debugging method, debugging device and readable storage medium

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