前言:我用 appium 在执行完注册功能之后,我想对通过调用自身的 open sdk 对登录状态做断言

@Test
    public void registerOtherAccount()
    {

        WebElement navigateLt = driver.findElementById("com.xxxx.sample:id/tabpage_indicator_parentview");
        List<WebElement> navigateRLList = navigateLt.findElements(By.className("android.widget.RelativeLayout"));
        navigateRLList.get(4).findElement(By.id("com.xxxxx.sample:id/tabindicator_image")).click();
        driver.findElementByName("使用其他帐户").click();
        driver.findElementByName("注册").click();
        List<WebElement> userTextList = driver.findElements(By.className("android.widget.EditText"));
        Random r = new Random();
        userTextList.get(0).sendKeys("test1369"+r.nextInt(10000));
        userTextList.get(1).sendKeys("qqqqqq");
        driver.findElementById("com.xxxxx.sample:id/usernameregister_register").click();
//调用自己的open sdk 来断言注册后的登录状态
        Assert.assertTrue(AccountManager.isLoggedIn());

    }

出现问题:引入 sdk project 后,一切正常,执行用例时,报如下错误

java.lang.NoClassDefFoundError: android/os/Handler$Callback
    at com.xxxx.open.AccountManager.isLoggedIn(AccountManager.java:114)
    at com.demo.sampleTest.registerOtherAccount(sampleTest.java:157)
    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:483)
    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)
Caused by: java.lang.ClassNotFoundException: android.os.Handler$Callback
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 27 more


疑问:Caused by: java.lang.ClassNotFoundException: android.os.Handler$Callback,是 appium 不可以使用源码吗?还是回调有什么问题。

求解答


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