<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## Android 'UIScrollable' 滑動(swipe): 簡單示例 Android的UIScrollable類在可滑動視圖中查找元素方面很有效。大多數情況下,你應該使用"scrllInfoView"類來執行滑動相關的操作,使得目標元素出現在屏幕中。 Android UIScrollable的[開發文檔](https://developer.android.google.cn/reference/androidx/test/uiautomator/UiScrollable) 以下場景我們可以使用UIScrollable滑動操作: - 在list中查找元素(例如,國家列表) - 查找未出現在屏幕中的元素(例如,輸入框,文本,按鈕) ScrollIntoView使用 UiSelector 作為查詢標準,允許你使用以下方式進行查詢元素: - 文本 方式(文本內容可以為:精確匹配,包含,匹配,以此文本開始,或是正則文本) - ID 方式 (支持 精確匹配或正則) - 其他不常用的方式(參考對應的開發文檔) - 上述方式組合使用 Android UiSelector的[開發文檔](https://developer.android.google.cn/reference/androidx/test/uiautomator/UiSelector) 此簡單示例中,我們默認只有一個可滾動視圖,滾動方向從屏幕底部滾動到頂部。 ![android-simple](https://img.kancloud.cn/66/e3/66e378769d6e8670dca659a94acfaf11_120x324.png) ### 以 文本 查找 ```java // Page object @AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().text(\"exact_text\"))") MobileElement element; @AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().textContains(\"part_text\"))") MobileElement element; // FindElement MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().text(\"exact_text\"))")); MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().textContains(\"part_text\"))")); ``` ### 以 ID 查找 ```java // Page object @AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().resourceIdMatches(\".*part_id.*\"))") MobileElement element; // FindElement MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().resourceIdMatches(\".*part_id.*\"))")); ``` ### ID和文本 組合查找 ```java // Page object @AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().resourceIdMatches(\".*part_id.*\").text(\"exact_text\"))") MobileElement element; // FindElement MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().resourceIdMatches(\".*part_id.*\").text(\"exact_text\"))")); ``` ### 長視圖問題 對于一些長視圖,需要設置"setMaxSearchSwipes"的值。這個參數的值決定在停止查找之前,最多滑動幾次。 ```java // set max swipes to 10 // FindElement MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true)).setMaxSearchSwipes(10)" + ".scrollIntoView(new UiSelector().text(\"exact_text\"))")); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看