Xcode7のXCTestでは...
app.alerts.collectionViews.buttons["hoge"].tap()
Xcode8のXCTestでは...
app.alerts.buttons["hoge"].tap()
-
collectionViews
を挟むと、XCUIElementQueryがアラートのボタンを見つけてくれなくなっているようだ
試しに(lldb)でpoすると...
-
po app.alerts.collectionViews.buttons
だとOutput:
が出ない
(lldb) po app.alerts.collectionViews.buttons
t = 320.73s Use cached accessibility hierarchy for hoge
t = 320.74s Find: Descendants matching type Alert
t = 320.75s Find: Descendants matching type CollectionView
Find: Target Application 0x6080000afd20
Output: {
Application 0x600000776b00: {{0.0, 0.0}, {414.0, 736.0}}, label: 'fuga'
}
↪︎Find: Descendants matching type Alert
Output: {
Alert 0x6000007777c0: traits: 72057602627862528, {{72.0, 237.7}, {270.0, 261.0}}, label: '退会'
}
↪︎Find: Descendants matching type CollectionView
↪︎Find: Descendants matching type Button
-
po app.alerts.buttons
だとちゃんと見つけてくれる
(lldb) po app.alerts.buttons
t = 116.83s Use cached accessibility hierarchy for hoge
t = 116.84s Find: Descendants matching type Alert
t = 116.85s Find: Descendants matching type Button
Find: Target Application 0x6080000afd20
Output: {
Application 0x600000776b00: {{0.0, 0.0}, {414.0, 736.0}}, label: 'fuga'
}
↪︎Find: Descendants matching type Alert
Output: {
Alert 0x6000007777c0: traits: 72057602627862528, {{72.0, 237.7}, {270.0, 261.0}}, label: '退会'
}
↪︎Find: Descendants matching type Button
Output: {
Button 0x6000007786c0: traits: 8589934593, {{72.0, 366.0}, {270.0, 44.0}}, label: '退会する'
Button 0x600000778e40: traits: 8589934593, {{72.0, 454.7}, {270.0, 44.0}}, label: 'キャンセル'
}
ネット上にある、XCTestのコードではapp.alerts.collectionViews.buttons["hoge"]
が結構多いけど、たぶん、Xcode8では正常に動かないと思う