2017-07-04 41 views

回答

3

您可以將accessibilityIdentifier值設置爲標籤欄項目。

tabBarItem.accessibilityIdentifier = "Your_Identifier"

在您UITest情況下,

guard let value = app.buttons["Your_Identifier"].value as? String 
else { 
    XCTFail("badge value not updated") 
    return 
} 
XCTAssert(value == "1 item", "badge value not updated") 

值將是格式 「number_on_badge項目(S)」。因此,在你的情況下,你應該測試「19項」。

+0

謝謝,作品!順便問一下,是否有可能在主屏幕上的應用程序圖標中測試徽章號碼? – brigadir