求助,我在 appium 使用 UIAutomator 进行定位时提示 java.lang.NoClassDefFoundError: com.android.uiautomator.core.Configurator 的错误,报错代码如下:
WebElement element = driver.findElementByAndroidUIAutomator("new UiSelector().clickable(true).className(\"android.widget.RelativeLayout\")");
element.click();
但是直接是用 UIAutomator 来进行查找是可以的,如下
UiObject dm = new UiObject(new UiSelector().clickable(true).className("android.widget.RelativeLayout"));
dm.clickAndWaitForNewWindow();
附错误日志(部分):
> info: --> POST /wd/hub/session/5dbadf02-4f61-4d4e-af75-696d2453357c/element {"using":"-android uiautomator","value":"new UiSelector().clickable(true).className(\"android.widget.RelativeLayout\")"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"-android uiautomator","selector":"new UiSelector().clickable(true).className(\"android.widget.RelativeLayout\")","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().clickable(true).className(\"android.widget.RelativeLayout\")","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding new UiSelector().clickable(true).className("android.widget.RelativeLayout") using ANDROID_UIAUTOMATOR with the contextId: multiple: false
> info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().clickable(true).className("android.widget.RelativeLayout")
> info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true
> info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: java.lang.Class<T> arg: "android.widget.RelativeLayout"
> info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: "android.widget.RelativeLayout"
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.RelativeLayout, CLICKABLE=true]
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] Error in testRunServer:
> info: [debug] [UIAUTOMATOR STDOUT] java.lang.NoClassDefFoundError: com.android.uiautomator.core.Configurator
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidElement.<init>(AndroidElement.java:26)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidElementsHash.addElement(AndroidElementsHash.java:47)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidElementsHash.getElement(AndroidElementsHash.java:89)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.handler.Find.fetchElement(Find.java:150)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.handler.Find.execute(Find.java:90)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidCommandExecutor.execute(AndroidCommandExecutor.java:64)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.runCommand(SocketServer.java:168)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.handleClientData(SocketServer.java:89)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.listenForever(SocketServer.java:133)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.Bootstrap.testRunServer(Bootstrap.java:16)
> info: [debug] [UIAUTOMATOR STDOUT] at java.lang.reflect.Method.invokeNative(Native Method)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:144)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:87)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:90)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
> info: [debug] [UIAUTOMATOR STDOUT] at dalvik.system.NativeStart.main(Native Method)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stack=java.lang.NoClassDefFoundError: com.android.uiautomator.core.Configurator
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidElement.<init>(AndroidElement.java:26)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidElementsHash.addElement(AndroidElementsHash.java:47)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidElementsHash.getElement(AndroidElementsHash.java:89)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.handler.Find.fetchElement(Find.java:150)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.handler.Find.execute(Find.java:90)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidCommandExecutor.execute(AndroidCommandExecutor.java:64)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.runCommand(SocketServer.java:168)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.handleClientData(SocketServer.java:89)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.listenForever(SocketServer.java:133)
> info: [debug] [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.Bootstrap.testRunServer(Bootstrap.java:16)
> info: [debug] [UIAUTOMATOR STDOUT] at java.lang.reflect.Method.invokeNative(Native Method)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:144)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:87)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:90)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
> info: [debug] [UIAUTOMATOR STDOUT] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
> info: [debug] [UIAUTOMATOR STDOUT] at dalvik.system.NativeStart.main(Native Method)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.E
> info: [debug] [UIAUTOMATOR STDOUT] Time: 13.086
> info: [debug] [UIAUTOMATOR STDOUT] FAILURES!!!
> info: [debug] [UIAUTOMATOR STDOUT] Tests run: 1, Failures: 0, Errors: 1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] UiAutomator exited