2016-10-10 12 views
0

XCode UI Testで以下のステップを実行すると、私は複数の出力を得ています。NSPrediccateを使用して出力のいずれかを選択

print(collectionViews.staticTexts.element(matching: NSPredicate(format: "(%@ IN identifiers), "price")).debugDescription) 

出力:

Find: Elements matching predicate '"price" IN identifiers' 
      Output: { 
      StaticText 0x608000375f00: traits: 8589934656, {{24.0, 384.0}, {197.0, 27.5}}, identifier: 'price', label: '123' 
      StaticText 0x6080003768c0: traits: 8589934656, {{24.0, 762.0}, {197.0, 27.5}}, identifier: 'price', label: '456' 
      } 

私は迅速を使用して単一の出力の代わりに、複数の出力を得ることができますとにかくあります。私はラベルであるを印刷しようとしています。私が探しています

出力:

注:ラベル値は変更し続けています。

答えて

0

テスト中に要素のインデックスがわかっている場合は、インデックスパスに基づいてaccessibilityIdentifierを定義し、その要素を取得するためにUIAutomationテストでその要素を使用できます。

例えば:

// suppose label has traits of a button 
label.accessibilityIdentifier = "<some constant>:\(indexPath.row)" 

// test class 
let label = table.buttons["<some constant>:\(<row index>)"] //this will give u only one element 
label.tap() 
関連する問題