gpt4 book ai didi

由于键盘启动弹出窗口,Android 仪器测试在 Google 的测试实验室 Galaxy S9+ 上失败

转载 作者:行者123 更新时间:2023-11-29 18:43:04 25 4
gpt4 key购买 nike

有时,仪器测试 (Espresso) 在 Google 的 Firebase 测试实验室会失败,原因是键盘启动弹出窗口(屏幕截图)会阻塞屏幕并阻止点击/键入事件。

这只发生在三星 Galaxy S9+ 上

enter image description here

异常(exception)情况:

android.support.test.espresso.PerformException: Error performing 'type text(666666)' on view '(is descendant of a: (with id: XXX) and an instance of android.widget.EditText)'.

Caused by: android.support.test.espresso.InjectEventSecurityException: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permissionat android.support.test.espresso.base.InputManagerEventInjectionStrategy.injectKeyEvent(InputManagerEventInjectionStrategy.java:113)

有什么建议吗?

最佳答案

在运行测试之前,也许您可​​以尝试使用来自 ADB 的“ime”命令来启用另一个键盘(例如,您可以记录 ime list 的返回以获取 ID) (例如@Before):

getInstrumentation().getUiAutomation().executeShellCommand("ime enable ID");
Thread.sleep(1000);
getInstrumentation().getUiAutomation().executeShellCommand("ime set ID");

否则,您可以使用 uiautomator 解决方法,并在通过此类代码使用键盘之前实现检查:

...
onView(withId(R.id.inputField)).perform(click());
if (Build.VERSION.SDK_INT >= 23) {
UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject skipButton = device.findObject(new UiSelector().text("SKIP"));
if (skipButton.exists()) {
try {
skipButton.click();
Timber.e(e, "Dismissed popup on Keyboard");
} catch (UiObjectNotFoundException e) {
Timber.e(e, "There is no popup displayed on Keyboard");
}
}
}
onView(withId(R.id.inputField)).perform(typeText("some"), pressImeActionButton());
...

希望对您有所帮助!

关于由于键盘启动弹出窗口,Android 仪器测试在 Google 的测试实验室 Galaxy S9+ 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52617816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com