Android Wireless Test-uiautomator uiscrollable API Introduction Seven
Last Update:2015-06-24
Source: Internet
Author: User
<span id="Label3"></p>Swipe to an object<p><p>one, swipe to an object-related API</p></p> <table style="width: 900px; height: 150px;" border="30" align="left"> <tbody> <tr> <td style="text-align: center;"><strong>return value</strong></td> <td style="text-align: center;"><strong>Api</strong></td> <td style="text-align: center;"><strong>Describe</strong></td> </tr> <tr> <td>Boolean</td> <td>scrollIntoView (uiselector Selector)</td> <td>Slide to the position of the conditional element and try to keep it centered on the screen</td> </tr> <tr> <td>Boolean</td> <td>scrollIntoView (UiObject Obj)</td> <td>Swipe to the Object's location and try to keep it centered on the screen</td> </tr> <tr> <td>Boolean</td> <td>Scrolltextintoview (String Text)</td> <td>Swipe to the location of the text object and try to keep it centered on the screen</td> </tr> <tr> <td>Boolean</td> <td>Scrolldescriptionintoview (String Text)</td> <td>Swipe to text to describe the Object's location, and try to keep it centered on the screen</td> </tr> <tr> <td>Boolean</td> <td>Scrolltobeginning (int maxswipes)</td> <td>Custom sweep count, swipe to start position</td> </tr> <tr> <td>Boolean</td> <td>scrolltobeginning (int maxswipes, int Steps)</td> <td>Custom sweep count and step, swipe to start position</td> </tr> <tr> <td>Boolean</td> <td>Scrolltoend (int maxswipes)</td> <td>Custom sweep count, swipe to end position</td> </tr> <tr> <td>Boolean</td> <td>Scrolltoend (int maxswipes, int Steps)</td> <td>Custom sweep count and step, swipe to end position</td> </tr> </tbody> </table><p><p></p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p>Note: all functions are to find out whether there is an object in the current interface, not found the first swipe up the specified number of sweep, and then swipe down while looking for this object, but also only swipe down the specified number of sweep, can not find the Error.</p></p><p><p>Ii. examples of relevant API applications</p></p><pre><span style="color: #0000ff;"><span style="color: #0000ff;"></span> package</span><span style="color: #000000;"><span style="color: #000000;">com.testuiselector;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Import</span></span><span style="color: #000000;"><span style="color: #000000;">com.android.uiautomator.core.UiDevice;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Import</span></span><span style="color: #000000;"><span style="color: #000000;">com.android.uiautomator.core.UiObject;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Import</span></span><span style="color: #000000;"><span style="color: #000000;">com.android.uiautomator.core.UiObjectNotFoundException;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Import</span></span><span style="color: #000000;"><span style="color: #000000;">com.android.uiautomator.core.UiScrollable;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Import</span></span><span style="color: #000000;"><span style="color: #000000;">com.android.uiautomator.core.UiSelector;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Import</span></span><span style="color: #000000;"><span style="color: #000000;">com.android.uiautomator.testrunner.UiAutomatorTestCase;</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">class</span></span>Demo<span style="color: #0000ff;"><span style="color: #0000ff;">extends</span></span><span style="color: #000000;"><span style="color: #000000;">Uiautomatortestcase {</span></span><span style="color: #008000;"><span style="color: #008000;">/**</span></span><span style="color: #008000;"><span style="color: #008000;"> * </span></span><span style="color: #808080;"><span style="color: #808080;">@param</span></span><span style="color: #008000;"><span style="color: #008000;">args</span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">Static</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">main (string[] Args) {String jarname, testclass, testname, androidid; Jarname</span></span>= "demo2"<span style="color: #000000;"><span style="color: #000000;">; TestClass</span></span>= "com.testuiselector.Demo"<span style="color: #000000;"><span style="color: #000000;">; TestName</span></span>= "testscrollintoview"<span style="color: #000000;"><span style="color: #000000;">; Androidid</span></span>= "1"<span style="color: #000000;"><span style="color: #000000;">; </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span><span style="color: #000000;"><span style="color: #000000;">uiautomatorhelper (jarname, testclass, testname, androidid); } </span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>Testscrollintoview ()<span style="color: #0000ff;"><span style="color: #0000ff;">throws</span></span><span style="color: #000000;"><span style="color: #000000;">uiobjectnotfoundexception{uidevice.getinstance (). presshome (); Sleep (</span></span>1000<span style="color: #000000;"><span style="color: #000000;">); UiObject people</span></span>=<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span>UiObject (<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span>Uiselector (). Text ("people"<span style="color: #000000;"><span style="color: #000000;">)); People.click (); Sleep (</span></span>2000<span style="color: #000000;"><span style="color: #000000;">); uiscrollable Scroll</span></span>=<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span>Uiscrollable (<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span>Uiselector (). ClassName ("android.widget.ListView"<span style="color: #000000;"><span style="color: #000000;">)); Scroll.scrolltobeginning (</span></span>50<span style="color: #000000;"><span style="color: #000000;">); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); Uiselector TestView</span></span>=<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span>Uiselector (). Text ("test"<span style="color: #000000;"><span style="color: #000000;">); Scroll.scrollintoview (testview); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); Scroll.scrolltobeginning (</span></span>50, 5<span style="color: #000000;"><span style="color: #000000;">); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); UiObject Test</span></span>=<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span><span style="color: #000000;"><span style="color: #000000;">UiObject (testview); Scroll.scrollintoview (test); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); Scroll.scrolltoend (</span></span>50<span style="color: #000000;"><span style="color: #000000;">); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); Scroll.scrolltextintoview (</span></span>"test"<span style="color: #000000;"><span style="color: #000000;">); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); Scroll.scrolltoend (</span></span>50,5<span style="color: #000000;"><span style="color: #000000;">); Sleep (</span></span>3000<span style="color: #000000;"><span style="color: #000000;">); Scroll.scrolldescriptionintoview (</span></span>"Quick Contact for test"<span style="color: #000000;"><span style="color: #000000;">); } }</span></span></pre><span class="cnblogs_code_collapse"><span class="cnblogs_code_collapse">Demo.java</span></span><p><p></p></p><p><p>Android Wireless Test-uiautomator uiscrollable API Introduction Seven</p></p></span>