=
summary:
A webview can find elements that are not inside the view.
But Appium's native_view cannot find elements that are not inside the view. This creates a problem in the scheme of wanting to swipe to an element.
webview can run js to slide.
native_view cannot use js.
=
refer to:
http://www.cnblogs.com/tobecrazy/p/4612133.html
http://blog.csdn.net/JuniorKang/article/details/52880458?locationNum=4&fps=1
http://blog.sina.com.cn/s/blog_bd6a57440102wm1x.html
=
Code:
driver (that is, pass in the appiudriver object)
During (here is to fill in the number of milliseconds, the smaller the number of milliseconds here, the faster the sliding speed~ Generally set at 500~1000, if you want to slide quickly, you can set it to a smaller value)
num (it’s only the number of times of swiping, I’m doing a photo album page-turning test or swiping to the bottom of the list. Just enter the number of times directly)
/** * Swipe up * * @param driver * @param during * @param swipeCount */ public static void swipeToUp(AppiumDriver driver,int during, int swipeCount) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; for (int i = 0; i < swipeCount; i++) { driver.swipe(width / 2, height * 3 / 4, width / 2, height / 4, during); CommonUtil.sleep(1000, "swipeToUp sleep when swipeCount > 0, now swipeCount=" + swipeCount + ","); } } /** * drop down * * @param driver * @param during * @param swipeCount */ public static void swipeToDown(AppiumDriver driver,int during, int swipeCount) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; System.out.println(width); System.out.println(height); for (int i = 0; i < swipeCount; i++) { driver.swipe(width / 2, height / 4, width / 2, height * 3 / 4, during); CommonUtil.sleep(1000, "swipeToDown sleep when swipeCount > 0, now swipeCount=" + swipeCount + ","); } } /** * Swipe left * * @param driver * @param during * @param swipeCount */ public static void swipeToLeft(AppiumDriver driver,int during, int swipeCount) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; for (int i = 0; i < swipeCount; i++) { driver.swipe(width * 3 / 4, height / 2, width / 4, height / 2, during); CommonUtil.sleep(1000, "swipeToLeft sleep when swipeCount > 0, now swipeCount=" + swipeCount + ","); } } /** * swipe right * * @param driver * @param during * @param swipeCount */ public static void swipeToRight(AppiumDriver driver, int during, int swipeCount) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; for (int i = 0; i < swipeCount; i++) { driver.swipe(width / 4, height / 2, width * 3 / 4, height / 2, during); CommonUtil.sleep(1000, "swipeToRight sleep when swipeCount > 0, now swipeCount=" + swipeCount + ","); } }
=
from:http://blog.sina.com.cn/s/blog_bd6a57440102wm1x.html
=
=
=