Configurator class Introduction and API Explanation 1.Configurator class introduction 1) To set the default delay of the script 2) function
A. Adjustable default time interval between two analog actions
B. Input time interval for adjustable input text
C. Adjustable time interval for each scroll
2. Related APIs
Delay term |
Default delay
|
Function description |
Api |
Action |
3s |
Set delay |
Setactionackonwledgmenttimeout (Long Timeout) |
Get default delay |
Getactionackonwledgmenttimeout () |
Keyboard input |
0s |
Set delay |
Setkeyinjectiondelay (Long delay) |
Get default delay |
Getkeyinjectiondelay () |
Rolling |
200ms |
Set delay |
Setscrollacknowledgmenttimeout (Long Timeout) |
Get default delay |
Getscrollacknowledgmenttimeout () |
Free |
10s |
Set delay |
Setwaitforidletimeout (Long Timeout) |
Get default delay |
Getwaitforidletimeout () |
Find components |
10s |
Set delay |
Setwaitforselectortimeout (Long Timeout) |
Get default delay |
Getwaitforselectortimeout () |
例如:
Public voidTestDemo1 ()throwsuiobjectnotfoundexception{//1.ActionAckonwledgmentTimeout () Longaction=configurator.getinstance (). Getactionacknowledgmenttimeout (); //output Default delaySYSTEM.OUT.PRINTLN ("Action default delay is:" +action); //Get screen height and width inty=uidevice.getinstance (). Getdisplayheight (); intx=uidevice.getinstance (). Getdisplaywidth (); //The default time delay under the action interval feelingUidevice.getinstance (). Swipe (x-10, Y/2, x-200, Y/2, 10); Uidevice.getinstance (). Swipe (x-10, Y/2, x-200, Y/2, 10); Sleep (2000); //Set DelayConfigurator.getinstance (). Setactionacknowledgmenttimeout (100000); //Use the set time delay to feel the action intervalUidevice.getinstance (). Swipe (x-10, Y/2, x-200, Y/2, 10); Uidevice.getinstance (). Swipe (x-10, Y/2, x-200, Y/2, 10); //after use, recall the default delay, remember!!! configurator.getinstance (). Setactionacknowledgmenttimeout (action); //2.KeyInjectionDelay () ' LongPrint=configurator.getinstance (). Getkeyinjectiondelay (); //output Keyboard input default delaySYSTEM.OUT.PRINTLN ("Keyboard input default delay is:" +print); //Get input BoxUiObject set=NewUiObject (NewUiselector (). ResourceId ("Com.android.mms:id/embedded_text_editor")); //feel the default delay input intervalSet.settext ("AABBCCD"); Sleep (2000); Set.cleartextfield (); //Modify the default delay to 1 secondsConfigurator.getinstance (). Setkeyinjectiondelay (1000); //feel the input interval after the change delaySet.settext ("AABBCCD"); Sleep (2000); Set.cleartextfield (); //Remember to change back to the original timeconfigurator.getinstance (). Setkeyinjectiondelay (print); //3.ScrollAcknowledgmentTimeout () LongScroll=configurator.getinstance (). Getscrollacknowledgmenttimeout (); //output Default delaySystem.out.println ("Scrolling default delay:" +scroll); //Get List CollectionUiscrollable scroll1=NewUiscrollable (NewUiselector (). ClassName ("Android.widget.ListView")); //Feel the default scrolling delay intervalScroll1.flingtoend (5); //Set the default scrolling time interval to 2SConfigurator.getinstance (). Setscrollacknowledgmenttimeout (2000); //Feel the scrolling time interval after settingScroll1.flingtoend (5); //Remember to change it back to the default time intervalconfigurator.getinstance (). Setscrollacknowledgmenttimeout (scroll); //4.WaitForIdleTimeout () Longwait=configurator.getinstance (). Getwaitforidletimeout (); System.out.println ("Idle default delay is:" +wait); //5.WaitForSelectorTimeout () LongSelector=configurator.getinstance (). Getwaitforselectortimeout (); //output Default time intervalSYSTEM.OUT.PRINTLN ("Lookup component default delay is:" +selector); //feel free to find an objectUiscrollable scroll2=NewUiscrollable (NewUiselector (). ClassName ("11321")); Scroll2.click (); //To Modify the default time intervalConfigurator.getinstance (). Setwaitforselectortimeout (1000); //feel the time interval after the changeUiscrollable scroll3=NewUiscrollable (NewUiselector (). ClassName ("11321")); Scroll3.click ();}
3. Example Demo 1) simulate double-click and Quick Multi-clicking action
//declaring Methods Public voidQuicklyclick (intNumintXinty) { //Get action interval time LongActiontime=configurator.getinstance (). Getactionacknowledgmenttimeout (); //Set action interval timeConfigurator.getinstance (). Setactionacknowledgmenttimeout (0); //Setup Action steps for(inti=0;i<=num;i++) {uidevice.getinstance (). Click (x, y); } //Finally, don't forget to restore the default time interval to avoid affecting other use cases laterconfigurator.getinstance (). Setactionacknowledgmenttimeout (Actiontime);}//Calling Methods Public voidTestDemo2 () {//Get screen height and width inty=uidevice.getinstance (). Getdisplayheight (); intx=uidevice.getinstance (). Getdisplaywidth (); //call the method body declared aboveQuicklyclick (4, X/2,Y/2);}
2) Use KeyCode fast input
//Setup Method Public voidquicklykeycode (String input) {//Get action interval time Longaction=configurator.getinstance (). Getactionacknowledgmenttimeout (); //Set action interval timeConfigurator.getinstance (). Setactionacknowledgmenttimeout (1); //the numbers used in the method come from the Androidkeycode table for(intI=0;i<input.length (); i++){ CharC=Input.charat (i); //judging the output if(c>48&&c<=57) {uidevice.getinstance (). Presskeycode (c-41); }Else if(c>=97&&c<=122) {uidevice.getinstance (). Presskeycode (c-68); }Else if(c>=65&&c<=90) {uidevice.getinstance (). Presskeycode (c-36,1); } } //don't forget to restore the defaultconfigurator.getinstance (). Setactionacknowledgmenttimeout (action);}//Calling Methods Public voidTestDemo3 () {Quicklykeycode ("Jian110");}
Detailed description of the 7.Configurator API