Appium findElementByAndroidUIAutomator 使用 UiScrollable,报错 java.lang.RuntimeException: Stub!

Aquarius、 · 2016年08月06日 · 最后由 Monkey 回复于 2016年08月06日 · 1977 次阅读

代码块

public void N004Add() throws Exception{
        driver.findElementById("com.ndol.sale.starter:id/fm_ll_address").click();
        driver.findElementById("com.ndol.sale.starter:id/iv_right").click();
        Thread.sleep(3000);
        driver.findElementById("com.ndol.sale.starter:id/ll_dormitory_area").click();
        UiScrollable list  = new UiScrollable(new UiSelector().className("android.widget.TextView"));
        String str = "楚翘城";
        driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollIntoView(new UiSelector().textContains(str))").click();
    } 

错误信息

java.lang.RuntimeException: Stub!</p>
at com.android.uiautomator.core.UiSelector.&lt;init&gt;(UiSelector.java:4)
at com.horse.Demo.N004Add(Demo.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:253)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Google 了一下说这个报错一般是因为调用了不属于自己的库,但是我已经导入了 uiautomator 的包,有点懵啊!

共收到 2 条回复 时间 点赞

WebElement element = driver.findElement(By.name("Element Name"));
HashMap arguments = new HashMap();
arguments.put("element", element.getID());
r.executeScript("mobile: scrollTo", arguments);
Java-client-4.1 scrollTo 没有 getID 的方法了,有没有其他更好的代替方法,除了滑动坐标

使用 markdown 编辑帖子!!!

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册