私は自分のiOSアプリケーション用にUITestsを実装しています。 これまでのところ、私は簡単なテストをすることができましたが、私は2つのセクションがあるtableViewに来ました。各セクションには、静的テキストを含むsectionHeaderViewがあります。 "セクション1"と "セクション2"、通常のsectionHeaderスタイル。XCTestでstaticTextを正しく見つける方法
app.tables.staticTexts["SECTION 1"].exists
を実行すると、true
が返されます。これは最初のセクションで、ビューが読み込まれたときに一番上に表示されます。
「SECTION 2」と同じ処理を実行するときは、false
を返します。このセクションのsectionHeaderViewはこの時点でビューの外にあるので、これは問題だと思っていましたが、そうではありません。 app.swipeUp()
を試しましたが、2番目のセクションが正常に画面に表示されました。スワイプアップしてから数秒間スリープしてビューが安定すると、同じチェックが実行されますが、2つ目のセクションビューを見つけることはできません。
は、スクロールダウンした後、私はそれが見つけることができるか見てapp.tables.staticTexts.debugDescription
をプリントアウトしようとしましたが、それが唯一の最初のセクションだけでなく、私はのtableViewの一番下に持ってtableFooterViewを示しています。
私がapp.tables.staticTexts["SECTION 2"].exists
を実行するとき、私は文字通りシミュレータ上の「セクション2」のテキストを見ることができます。それでもテストには存在しません。
2番目のsectionHeaderViewがXCTestに完全に見えないのはなぜですか?私は、特にこの視点で何らかのアクセシビリティを無効にしている可能性がありますか?私はまだコメントできないため、
t = 32.25s Find: Descendants matching type Table
t = 32.26s Find: Descendants matching type StaticText
t = 32.26s Find: Elements matching predicate '"SECTION 1" IN identifiers'
Found SECTION 1. Will scroll down to find Section 2.
t = 32.26s Swipe up Target Application 0x6080000bbf60
t = 32.26s Wait for app to idle
t = 32.30s Find the Target Application 0x6080000bbf60
t = 32.30s Snapshot accessibility hierarchy for my.bundle.identifier
t = 33.09s Wait for app to idle
t = 33.14s Synthesize event
t = 33.42s Wait for app to idle
Slept for 3 seconds. Have scrolled down. SECTION 2 in view now.
t = 38.86s Snapshot accessibility hierarchy for my.bundle.identifier
t = 39.64s Find: Descendants matching type Table
t = 39.65s Find: Descendants matching type StaticText
t = 39.65s Find: Elements matching predicate '"SECTION 2" IN identifiers'
t = 39.66s Assertion Failure: MyUITests.swift:347: XCTAssertTrue failed - SECTION 2 does not exist
t = 39.66s Tear Down
あなたは、第二のセクションを見てみるとヘッダーには、キャッシュされたスナップショット/階層を使用していると出力されますか? – Oletha
@Oletha No ..それが何を言っているの更新された質問を参照してください。 – Sti