我正在使用装有Lollipop Android操作系统的Nexus 5和Cyanogen One plus设备,并与某个应用程序的各种通知进行测试。我成功地使用UiAutomator测试了托盘通知和锁屏通知,但是我无法成功地获得悬浮通知。我尝试了以下代码,但未能检测到它。
public void test_HeadsupTitle() throws InterruptedException, UiObjectNotFoundException, IOException
{
//some code to bring up headsup notification
UiObject maxHeadsUp = new UiObject(new UiSelector().packageName("com.android.systemui").resourceId("android:id/status_bar_latest_event_content"));
// code to add sleep so that it waits for heads up notification to show up
assertTrue(maxHeadsUp.exists());
}
有没有办法在运行自动化时将headsup通知检测为要查找的对象?