如何使用appium scrollto函数使用其ID滚动到元素

时间:2015-11-13 11:36:51

标签: appium scrollto

我想使用appium scrollto滚动到ID的元素。

我该怎么做?目前只能在scrollto功能中输入文字。

1 个答案:

答案 0 :(得分:-1)

我正在使用一些Javascript代码来实现这一目标。也许这也可以帮到你。但是,每个解决方案都是针对问题的(即App)。现在我也不知道你是如何得到你的问题,因为它显示零研究,并没有提供任何信息。

No mention of Android OS or iOS, 
No mention of application type - Hybrid, Native, etc.
No mention of what you have achieved until now with scrollto any snippet etc.

说过我要在我的代码中分享一些我正在使用的Javascript。这又是我的应用程序特有的。也许你需要一个更加量身定制的解决方案来解决你的问题。

public class Scroll extends Driver{

    public static void scrolldown(){
        //Scroll JS
        JavascriptExecutor js = (JavascriptExecutor) Ad ;
        HashMap<String, String> scrollObject = new HashMap<String, String>();
        scrollObject.put("direction", "down");
        js.executeScript("mobile: scroll", scrollObject);
    }

    public static void scrollup(){
        //Scroll JS
        JavascriptExecutor js = (JavascriptExecutor) Ad ;
        HashMap<String, String> scrollObject = new HashMap<String, String>();
        scrollObject.put("direction", "up");
        js.executeScript("mobile: scroll", scrollObject);
    }
}