我们是基于 Uiautomator 自己做了个PC端可视化工具
可以,重写 longclick ,自己传个参数进去 想长按多久就多久
/**
* 重写控件长按操作
* @param ud
* @param uiObject
* @param steps
* @throws UiObjectNotFoundException
*/
public void longClick(UiDevice ud, UiObject uiObject,int steps) throws UiObjectNotFoundException{
ud.swipe(uiObject.getBounds().centerX(), uiObject.getBounds().centerY(),
uiObject.getBounds().centerX(), uiObject.getBounds().centerY(), steps);
}
例如:longClick(getUiDevice(), sw, 100);
请问下楼主,能不能分享下源码?
关于 swt,我自己也重新编译了 Uiautomatorviewer,可是一直报如下的错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-cocoa-3550 or swt-cocoa in swt.library.path, java.library.path or the jar file
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.(Unknown Source)
at org.eclipse.swt.internal.cocoa.NSThread.isMainThread(Unknown Source)
at org.eclipse.swt.graphics.Device.(Unknown Source)
at org.eclipse.swt.widgets.Display.(Unknown Source)
at org.eclipse.swt.widgets.Display.(Unknown Source)
at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
at org.eclipse.swt.widgets.Shell.(Unknown Source)
at org.eclipse.swt.widgets.Shell.(Unknown Source)
at org.eclipse.jface.window.Window.createShell(Window.java:487)
at org.eclipse.jface.window.Window.create(Window.java:430)
at org.eclipse.jface.window.Window.open(Window.java:790)
at com.android.uiautomator.UiAutomatorViewer.main(UiAutomatorViewer.java:90)
按照网上的说法换了好几次 swt 一直没解决,求帮忙
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-cocoa-3550 or swt-cocoa in swt.library.path, java.library.path or the jar file
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.(Unknown Source)
at org.eclipse.swt.internal.cocoa.NSThread.isMainThread(Unknown Source)
at org.eclipse.swt.graphics.Device.(Unknown Source)
at org.eclipse.swt.widgets.Display.(Unknown Source)
at org.eclipse.swt.widgets.Display.(Unknown Source)
at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
at org.eclipse.swt.widgets.Shell.(Unknown Source)
at org.eclipse.swt.widgets.Shell.(Unknown Source)
at org.eclipse.jface.window.Window.createShell(Window.java:487)
at org.eclipse.jface.window.Window.create(Window.java:430)
at org.eclipse.jface.window.Window.open(Window.java:790)
at com.android.uiautomator.UiAutomatorViewer.main(UiAutomatorViewer.java:90)
替换了好几个 swt 一运行就这样
@kasi 出现和 10 楼一样的问题,我试了很多都没有解决,我的电脑是 64 位的,替换了你 github 上的那个 jar 发现没有出现右键的一些属性,求帮忙,最近在学这个,很感谢你的分享
查找了 N 多资料搞定了,谢谢