• 感谢楼主分享,经过尝试有两个地方需要注意下sdcard中要有jacoco文件夹否则创建ec文件时会抛异常,build.gradle里面需要添加testCoverageEnabled = true,否则也会报异常

  • 是的 需要手动执行, 或者找个root的android设备写个能执行adb shell命令的apk,直接在apk里执行shell脚本

  • 重启后可以通过连接USB线然后执行下面命令来重启服务
    adb shell /data/local/tmp/atx-agent server --server 192.168.101.209:8000 -d

  • 请问你这问题解决了吗
    我也遇到同样问题,一直没找到解决方法😭

  • 其实楼主离成功只差一步了 需要在前面加个@Rule

    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
    MainActivity.class);

    @Test
    public void testScreenshot() throws InterruptedException {
    mDevice.pressHome();
    Thread.sleep(2);
    Activity ss=mActivityRule.getActivity();
    Spoon.screenshot(ss,"aaa");
    }
  • uiautomator2.0 用 as 运行出错 at February 17, 2017
    1. 测试类要放在androidTest下面
    2. 执行测试的时候要在Run/Debug Configurations里新建一个用于android test的配置。
  • 虽然uiautomator检测不到悬浮闹钟提示控件,但是直接用 mDevice.wait(Until.findObject(By.text("Dismiss")),120000).click(); 还是可以在闹钟响的时候点击到取消的,实测andorid 6.0的机器上可用

  • 感谢分享 请教楼主代码中关于refresh的部分,取消注释的话能正常刷新界面嘛

    //click(refresh) item15-19

    item15.addSelectionListener(new SelectionAdapter(){
    @Override
    public void widgetSelected(SelectionEvent e){
    objectClick();
    //UiAutomatorViewer window=UiAutomatorViewer.getInstance();
    //ScreenshotAction screenshot=new ScreenshotAction(window, false);
    //screenshot.run();
    }
    });

    我这里总是报下面的错误

    Unhandled event loop exception during blocked modal context.
    org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Unknown Source)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:173)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:388)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
    at com.android.uiautomator.actions.ScreenshotAction.run(ScreenshotAction.java:85)
    at com.android.uiautomator.UiAutomatorView$3$6.widgetSelected(UiAutomatorView.java:324)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at com.android.uiautomator.UiAutomatorViewer.main(UiAutomatorViewer.java:91)
    Caused by: java.lang.NullPointerException
    at com.android.uiautomator.UiAutomatorViewer$1.run(UiAutomatorViewer.java:117)
    at org.eclipse.swt.widgets.RunnableLock.run(Unknown Source)
    ... 16 more
    java.lang.NullPointerException
    at com.android.uiautomator.actions.ScreenshotAction.showError(ScreenshotAction.java:108)
    at com.android.uiautomator.actions.ScreenshotAction.run(ScreenshotAction.java:103)
    at com.android.uiautomator.UiAutomatorView$3$6.widgetSelected(UiAutomatorView.java:324)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at com.android.uiautomator.UiAutomatorViewer.main(UiAutomatorViewer.java:91)



  • 打造专属 uiautomatorviewer at April 28, 2016

    #15楼 @niuniudd 大侠能把你的刷新部分代码贴出来吗 菜鸟连刷新都还没搞定呢..