@nieschumiまずこのタスクのように見えるのは、ui用ではありません。
/*! Returns a new query that applies the specified attributes or predicate to the receiver. The predicate will be evaluated against objects of type id<XCUIElementAttributes>. */
open func matching(_ predicate: NSPredicate) -> XCUIElementQuery
open func matching(_ elementType: XCUIElementType, identifier: String?) -> XCUIElementQuery
open func matching(identifier: String) -> XCUIElementQuery
/*! Returns a new query for finding elements that contain a descendant matching the specification. The predicate will be evaluated against objects of type id<XCUIElementAttributes>. */
open func containing(_ predicate: NSPredicate) -> XCUIElementQuery
open func containing(_ elementType: XCUIElementType, identifier: String?) -> XCUIElementQuery
: ので、なぜuが関数のいずれかを使用することはできませんか? uは
例が必要な場合や、クエリのチェック回数より:
app.buttons.matching(NSPredicate(format: "label == [cd] %@", myVar)).count>1 ? doSmthWithQuery(): doSmthWithElement()
出典
2017-05-16 15:09:45
Che
これは、あなたの質問に答えていませんが、私は、これはユニットテストではなく、UIテストされるべきだと思います。ここで機能をテストしています(文字 "p"を検索し、リストを取得します)。 UIテストでは、「検索」ボタンをクリックした後にラベル(またはリスト)が表示されることを確認するだけです。その内容にあまり関心を持ってはならない。 – Hodson
@ Hodson私はあなたに同意します、私はいつもUIテストがどのくらい詳細に検証されるべきかについて苦労します – nieschumi