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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 簡單的元素Swipe ### Android的UIAutomator2 默認的UIAutomator2只返回在屏幕上可以看到的元素。如果可見視圖和不可見視圖分隔了某個容器,那么此容器中一部分內容將無法(被UIAutomator2)識別到。 ![simple-element-swipe.png](https://img.kancloud.cn/da/2b/da2b08757c398030a5f0f82c8b04889c_116x248.png) ```java /** * Performs swipe inside an element * * @param el the element to swipe * @param dir the direction of swipe * @version java-client: 7.3.0 **/ public void swipeElementAndroid(MobileElement el, Direction dir) { System.out.println("swipeElementAndroid(): dir: '" + dir + "'"); // always log your actions // Animation default time: // - Android: 300 ms // - iOS: 200 ms // final value depends on your app and could be greater final int ANIMATION_TIME = 200; // ms final int PRESS_TIME = 200; // ms int edgeBorder; PointOption pointOptionStart, pointOptionEnd; // init screen variables Rectangle rect = el.getRect(); // sometimes it is needed to configure edgeBorders // you can also improve borders to have vertical/horizontal // or left/right/up/down border variables edgeBorder = 0; switch (dir) { case DOWN: // from up to down pointOptionStart = PointOption.point(rect.x + rect.width / 2, rect.y + edgeBorder); pointOptionEnd = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height - edgeBorder); break; case UP: // from down to up pointOptionStart = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height - edgeBorder); pointOptionEnd = PointOption.point(rect.x + rect.width / 2, rect.y + edgeBorder); break; case LEFT: // from right to left pointOptionStart = PointOption.point(rect.x + rect.width - edgeBorder, rect.y + rect.height / 2); pointOptionEnd = PointOption.point(rect.x + edgeBorder, rect.y + rect.height / 2); break; case RIGHT: // from left to right pointOptionStart = PointOption.point(rect.x + edgeBorder, rect.y + rect.height / 2); pointOptionEnd = PointOption.point(rect.x + rect.width - edgeBorder, rect.y + rect.height / 2); break; default: throw new IllegalArgumentException("swipeElementAndroid(): dir: '" + dir + "' NOT supported"); } // execute swipe using TouchAction try { new TouchAction(driver) .press(pointOptionStart) // a bit more reliable when we add small wait .waitAction(WaitOptions.waitOptions(Duration.ofMillis(PRESS_TIME))) .moveTo(pointOptionEnd) .release().perform(); } catch (Exception e) { System.err.println("swipeElementAndroid(): TouchAction FAILED\n" + e.getMessage()); return; } // always allow swipe action to complete try { Thread.sleep(ANIMATION_TIME); } catch (InterruptedException e) { // ignore } } ``` ### iOS的XCUITest XCUITest可以顯示屏幕外的元素。強烈建議使用屏幕滑動(screen swipe)或'mobile:scroll' / 'mobile:swipe' 方法。如果你需要或更傾向于使用元素相關的方法,需要考慮以下內容: 1. 檢查確保起始點和結束點都在屏幕區域之內。 2. 滾動視圖通常是背景元素。頁面/頁腳或其他元素覆蓋在滾動視圖之上,限制了滾動性。嘗試配置正確的邊界以保證滾動性。如果不同屏幕上的邊界有差異,應該通過swipe方法的參數進行配置化處理。 ```java /** * Performs swipe inside an element * * @param el the element to swipe * @param dir the direction of swipe * @version java-client: 7.3.0 **/ public void swipeElementIOS(MobileElement el, Direction dir) { System.out.println("swipeElementIOS(): dir: '" + dir + "'"); // always log your actions // Animation default time: // - Android: 300 ms // - iOS: 200 ms // final value depends on your app and could be greater final int ANIMATION_TIME = 200; // ms final int PRESS_TIME = 500; // ms // init screen variables Dimension dims = driver.manage().window().getSize(); Rectangle rect = el.getRect(); // check element overlaps screen if (rect.x >= dims.width || rect.x + rect.width <= 0 || rect.y >= dims.height || rect.y + rect.height <= 0) { throw new IllegalArgumentException("swipeElementIOS(): Element outside screen"); } // init borders per your app screen // or make them configurable with function variables int leftBorder, rightBorder, upBorder, downBorder; leftBorder = 0; rightBorder = 0; upBorder = 0; downBorder = 0; // find rect that overlap screen if (rect.x < 0) { rect.width = rect.width + rect.x; rect.x = 0; } if (rect.y < 0) { rect.height = rect.height + rect.y; rect.y = 0; } if (rect.width > dims.width) rect.width = dims.width; if (rect.height > dims.height) rect.height = dims.height; PointOption pointOptionStart, pointOptionEnd; switch (dir) { case DOWN: // from up to down pointOptionStart = PointOption.point(rect.x + rect.width / 2, rect.y + upBorder); pointOptionEnd = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height - downBorder); break; case UP: // from down to up pointOptionStart = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height - downBorder); pointOptionEnd = PointOption.point(rect.x + rect.width / 2, rect.y + upBorder); break; case LEFT: // from right to left pointOptionStart = PointOption.point(rect.x + rect.width - rightBorder, rect.y + rect.height / 2); pointOptionEnd = PointOption.point(rect.x + leftBorder, rect.y + rect.height / 2); break; case RIGHT: // from left to right pointOptionStart = PointOption.point(rect.x + leftBorder, rect.y + rect.height / 2); pointOptionEnd = PointOption.point(rect.x + rect.width - rightBorder, rect.y + rect.height / 2); break; default: throw new IllegalArgumentException("swipeElementIOS(): dir: '" + dir + "' NOT supported"); } // execute swipe using TouchAction try { new TouchAction(driver) .press(pointOptionStart) // a bit more reliable when we add small wait .waitAction(WaitOptions.waitOptions(Duration.ofMillis(PRESS_TIME))) .moveTo(pointOptionEnd) .release().perform(); } catch (Exception e) { System.err.println("swipeElementIOS(): TouchAction FAILED\n" + e.getMessage()); return; } // always allow swipe action to complete try { Thread.sleep(ANIMATION_TIME); } catch (InterruptedException e) { // ignore } } ```
                  <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>

                              哎呀哎呀视频在线观看