我想通过 Play 商店自动安装和打开应用程序。 这是代码:
// Search for Install Button in Google Play Store and click it
SearchCondition<UiObject2> isAvailableInstall = Until.findObject(By.textContains(install));
device.wait(isAvailableInstall, 100000);
UiObject installButton = device.findObject(new UiSelector()
.textContains(install));
if (installButton.exists()) {
installButton.click();
}
// Open App after install
//TODO: FIX
device.wait(Until.findObject(By.textContains(open)), 100000);
UiObject openButton = device.findObject(new UiSelector()
.textContains(open));
if (openButton.exists()) {
openButton.click();
}
"install"和 "open"是带有按钮特定语言名称的字符串(英文 INSTALL 和 OPEN) 有时,他在设备中找不到打开按钮。等待和超时。为什么?
最佳答案
您在这里提出的问题,似乎为应用程序设置的安装时间可能不够好,无法将应用程序安装到设备中。另一种可能性是设备的默认语言可能不是英语。
我建议您使用 resourceID
,而不是通过根据内容文本识别按钮来单击按钮。
关于android - 等待并单击按钮以在 Playstore 中安装和打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55649503/