测试用例里面输入框输入中文,调用的是 utf7ime 输入法,但是报错 提示:java.lang.RuntimeException: Stub!

Java 源代码:

package com.incito.appiumdemo;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.HasTouchScreen;
import org.openqa.selenium.interactions.TouchScreen;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteTouchScreen;
import org.openqa.selenium.remote.RemoteWebDriver;

import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;

import java.io.File;
import java.net.URL;
import java.util.List;

import jp.jun_nama.test.utf7ime.helper.Utf7ImeHelper;

public class EduLogin {
    private WebDriver driver;

    @Before
    public void setUp() throws Exception {

        File classpathRoot = new File(System.getProperty("user.dir"));
        File appDir = new File(classpathRoot, "apps");
        File app = new File(appDir, "Education_136_8082.apk");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("device","Android");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability(CapabilityType.VERSION, "4.2.2");
        capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("app-package", "com.incito.education.app");
        capabilities.setCapability("app-activity", "com.incito.education.activity.V2MenuActivity");
        driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

    }

    @After
    public void tearDown() throws Exception {
      // driver.quit();
    }

    @Test
    public void loginEdu(){

        //登陆
       List<WebElement> textFieldsList = driver.findElements(By.tagName("textfield"));
       try {
           new UiObject(new UiSelector().className("android.widget.EditText"))
           .setText(Utf7ImeHelper.e("你好"));
    } catch (UiObjectNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

      // textFieldsList.get(0).sendKeys("gaoyun");
        textFieldsList.get(1).sendKeys("123456");
        List<WebElement > LoginButtons = driver.findElements(By.tagName("button"));
        LoginButtons.get(2).click();
     //进入家校社区
        List<WebElement > HomeButtons = driver.findElements(By.tagName("button"));
        HomeButtons.get(1).click();
       //查看家庭作业
        for (int i = 1; i < 5; i++) {

          WebElement homework = driver.findElement(By.xpath("//RadioGroup/RadioButton["+i+"]"));
          homework.click();
        }



    }

    public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
        private RemoteTouchScreen touch;

        public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
            super(remoteAddress, desiredCapabilities);
            touch = new RemoteTouchScreen(getExecuteMethod());
        }

        public TouchScreen getTouch() {
            return touch;
        }
    }
}

错误代码:

java.lang.RuntimeException: Stub!
    at com.android.uiautomator.core.UiSelector.<init>(UiSelector.java:4)
    at com.incito.appiumdemo.EduLogin.addContact(EduLogin.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    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.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



↙↙↙阅读原文可查看相关链接,并与作者交流