如何使用 appium 自动化在 android 上收到推送通知时自动化测试用例以断言?
我想在收到推送通知时自动执行测试用例。 如何检查是否收到推送通知? 如何检查推送通知是否来 self 的应用程序(包)? 如何断言这个推送通知是我的并且接收成功?
最佳答案
您可以使用以下代码获取所有通知标题,然后对其进行迭代。
driver.openNotifications();
List<WebElement> allnotifications=driver.findElements(By.id("android:id/title"));
for (WebElement webElement : allnotifications) {
System.out.println(webElement.getText());
if(webElement.getText().contains("something")){
System.out.println("Notification found");
break;
}
}
关于android - 使用 Appium 推送通知自动化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34430858/