【发布时间】:2015-01-19 09:52:21
【问题描述】:
我想向下滚动到页面底部,然后执行一项操作。使用uiautomator,我得到了以下信息:
index=2,
resource-id=com.manoramaonline.arogyam:id/pager,class=android.support.v4.view.ViewPager,
scrollable=true.
我试图用下面的代码做到这一点:
JavascriptExecutor js = (JavascriptExecutor) driver;
RemoteWebElement element =(RemoteWebElement)driver.findElement(By.xpath("//android.support.v4.view.ViewPager[@resource-id='com.manoramaonline.arogyam:id/pager']"));
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
// This is where the error is
scrollObject.put("element", element.getId());
js.executeScript("mobile: scroll", scrollObject);
【问题讨论】:
-
您能否添加一些有关您的自动化的详细信息,例如正在使用的操作系统、自动化应用程序操作系统、您正在使用的 appium 版本等
-
我正在为安卓应用创建脚本,appium版本是AppiumForWindows-1.2.4.1
-
我能够使用以下代码向下滚动,WebElement element = driver.findElement(By.className("android.widget.ScrollView")); HashMap
arguments = new HashMap ();arguments.put("element", ((RemoteWebElement) element).getId()); ((JavascriptExecutor) 驱动程序).executeScript("mobile: scrollTo", arguments);但得到异常信息:[debug] 以错误响应客户端:{"status":13,"value":{"message":"处理命令时发生未知的服务器端错误。","origValue":"无法将元素滚动到视图中: -
@PramodKumarG 你有任何滚动解决方案吗?我也面临同样的问题
-
@testing,我的问题解决了,正如我在下面的答案中提到的那样
标签: javascript selenium-webdriver appium