Cle*_* B. 5 java android ui-automation android-uiautomator
我在 Appium/Python 中有:
//calculation max_height
//calculation of max_width
action = TouchAction(self.driver)
action.tap(None, max_width, max_height).release().perform()
Run Code Online (Sandbox Code Playgroud)
我的目标是执行相同的操作,但是在 Java 中使用 UIautomator 工具。我已经尝试了下一个脚本,但它不起作用。
UiObject appButton = new UiObject(new UiSelector());
appButton.click(int x, int y);
Run Code Online (Sandbox Code Playgroud)
我的应用程序是在 Unity 中制作的,并且没有任何定位器的可访问性,因此我必须使用屏幕上的 XY 位置。
有人解决这个问题吗?谢谢。
我这样做的方式是使用UIDevice
, 而不是UIObject
(UIObject 用于调用应用程序内的特定方法或操作,但 UIDevice 用于设备事物,例如单击 X/Y,或按后退/主页按钮)
@RunWith(AndroidJUnit4.class)
public class SomeClass {
.... some setup and stuff...
@Test
public void testCoordinates() {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
device.click(42, 242);
}
}
Run Code Online (Sandbox Code Playgroud)
其中 42 是 X,242 是 Y,从屏幕左上角开始。
归档时间: |
|
查看次数: |
4588 次 |
最近记录: |