2017-06-04 66 views

回答

1

您應該設置一個accessibilityIdentifier。這是一個非面向用戶的屬性,旨在讓您識別UI測試中的元素。它被引入以阻止人們濫用accessibilityLabel,人們以前會使用它們來識別測試中的事物,但是這會影響配音用戶的體驗,他們在選擇元素時會聽到accessibilityLabel的內容。

// app code 
let myButton: UIButton! 
myButton.accessibilityIdentifier = "deleteButton" 

// test code 
let app = XCUIApplication() 
let deleteButton = app.buttons["deleteButton"] 
0

您可以通過accessibilityLabel找到按鈕。因此,首先設置標籤:

deleteButton.setAccessibilityLabel("delete") 

然後你就可以用它訪問正常:

untitledWindow.buttons["delete"].click() 
相關問題