<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # ScrollTo ~~~ package io.appium.android.bootstrap.handler; import com.android.uiautomator.core.UiObject; import com.android.uiautomator.core.UiObjectNotFoundException; import com.android.uiautomator.core.UiScrollable; import com.android.uiautomator.core.UiSelector; import io.appium.android.bootstrap.*; import org.json.JSONException; import java.util.Hashtable; /** * This handler is used to scroll to elements in the Android UI. * * Based on the element Id of the scrollable, scroll to the object with the * text. * */ public class ScrollTo extends CommandHandler { /* * @param command The {@link AndroidCommand} * * @return {@link AndroidCommandResult} * * @throws JSONException * * @see io.appium.android.bootstrap.CommandHandler#execute(io.appium.android. * bootstrap.AndroidCommand) */ @Override public AndroidCommandResult execute(final AndroidCommand command) throws JSONException { if (!command.isElementCommand()) { return getErrorResult("A scrollable view is required for this command."); } try { Boolean result; final Hashtable<String, Object> params = command.params(); final String text = params.get("text").toString(); final String direction = params.get("direction").toString(); final AndroidElement el = command.getElement(); if (!el.getUiObject().isScrollable()) { return getErrorResult("The provided view is not scrollable."); } final UiScrollable view = new UiScrollable(el.getUiObject().getSelector()); if (direction.toLowerCase().contentEquals("horizontal") || view.getClassName().contentEquals( "android.widget.HorizontalScrollView")) { view.setAsHorizontalList(); } view.scrollToBeginning(100); view.setMaxSearchSwipes(100); result = view.scrollTextIntoView(text); view.waitForExists(5000); // make sure we can get to the item UiObject listViewItem = view.getChildByInstance( new UiSelector().text(text), 0); // We need to make sure that the item exists (visible) if (!(result && listViewItem.exists())) { return getErrorResult("Could not scroll element into view: " + text); } return getSuccessResult(result); } catch (final UiObjectNotFoundException e) { return new AndroidCommandResult(WDStatus.NO_SUCH_ELEMENT, e.getMessage()); } catch (final NullPointerException e) { // el is null return new AndroidCommandResult(WDStatus.NO_SUCH_ELEMENT, e.getMessage()); } catch (final Exception e) { return new AndroidCommandResult(WDStatus.UNKNOWN_ERROR, e.getMessage()); } } } ~~~ 在uiautomator中有時候需要在一個滾動的list中找到某一個item,而這個item的位置又不定,這個時候我們可以通過UiScrollable的scrollTo來找到特定text的控件。而bootstrap的這個ScrollTo就是封裝這樣一種需求的。 首先判斷控件是否是可以滾動的,然后創建UiScrollable對象,因為默認的滾動方式是垂直方向的,如果需要的是水平方向的的話,還要設置方向為水平。 ~~~ view.setAsHorizontalList(); ~~~ 然后將滾動控件滾到最開始的地方,然后設置最大的搜索范圍為100次,因為不可能永遠搜索下去。然后開始調用 ~~~ view.scrollTextIntoView(text); ~~~ 開始滾動,最后確認是否滾動到制定目標: ~~~ view.waitForExists(5000); ~~~ 因為有可能有刷新到時間,所以調用方法到時候傳入了時間5秒鐘。 ~~~ UiObject listViewItem = view.getChildByInstance( new UiSelector().text(text), 0); ~~~ 最后檢查結果,獲取制定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>

                              哎呀哎呀视频在线观看