@@ -16,7 +16,9 @@ final class WebNavUITests: ShellTestCase {
1616 /// The open drawer: a modal web dialog named "Sidebar" (the page hides everything outside it,
1717 /// its toggle included, so "Hide sidebar" is never there while it is open).
1818 private func drawer ( _ app : XCUIApplication ) -> XCUIElement {
19- app . webViews . descendants ( matching : . any ) . matching ( NSPredicate ( format : " label BEGINSWITH 'Sidebar' " ) ) . firstMatch
19+ // An exact name on a typed query: a predicate over every element of the page timed out while
20+ // the drawer was open (runs 46196901125, 46204085752).
21+ app . webViews . otherElements [ " Sidebar " ]
2022 }
2123
2224 /// Opens the drawer: taps "Show sidebar" and waits for the dialog; taps again only while the
@@ -43,7 +45,7 @@ final class WebNavUITests: ShellTestCase {
4345 /// Rivera, Acme"); never Settings' "Name: Sam Rivera" row. Opens the drawer first.
4446 private func accountButton ( _ app : XCUIApplication ) -> XCUIElement ? {
4547 openDrawer ( app )
46- return firstExisting ( [ app . webViews . descendants ( matching : . any ) . matching ( NSPredicate ( format : " label BEGINSWITH ' Sam Rivera,' " ) ) . firstMatch ] ,
48+ return firstExisting ( [ app . webViews . otherElements [ " Sam Rivera, Acme " ] , app . webViews . buttons [ " Sam Rivera, Acme " ] ] ,
4749 timeout : 10 )
4850 }
4951
@@ -85,7 +87,7 @@ final class WebNavUITests: ShellTestCase {
8587 var row = app . webViews . links . matching ( NSPredicate ( format : " label CONTAINS 'Quarterly forecast' " ) ) . firstMatch
8688 if ! row . waitForExistence ( timeout : 8 ) {
8789 // The drawer opened on another section: Chats first.
88- let chats = app . webViews . descendants ( matching : . any ) . matching ( NSPredicate ( format : " label BEGINSWITH ' Chats' " ) ) . firstMatch
90+ let chats = app . webViews . switches [ " Chats " ]
8991 if chats . waitForExistence ( timeout : 5 ) { chats . tap ( ) }
9092 row = app . webViews . links . matching ( NSPredicate ( format : " label CONTAINS 'Quarterly forecast' " ) ) . firstMatch
9193 }
@@ -142,7 +144,7 @@ final class WebNavUITests: ShellTestCase {
142144 return
143145 }
144146 account . tap ( )
145- let signOut = firstExisting ( [ webElement ( app , label : " Sign out " ) , webText ( app , " Sign out " ) ] , timeout : 10 )
147+ let signOut = firstExisting ( [ app . webViews . menuItems [ " Sign out " ] , app . webViews . buttons [ " Sign out " ] ] , timeout : 10 )
146148 sleep ( 1 )
147149 screenshot ( " 8-account-menu " )
148150 guard let signOut = signOut else {
@@ -167,7 +169,8 @@ final class WebNavUITests: ShellTestCase {
167169 /// Opens the drawer and taps a section on its strip (Chats, Bots) or a row in its panel.
168170 private func fromDrawer ( _ app : XCUIApplication , _ label : String ) -> Bool {
169171 guard openDrawer ( app ) else { return false }
170- let item = app . webViews . descendants ( matching : . any ) . matching ( NSPredicate ( format : " label BEGINSWITH %@ " , label ) ) . firstMatch
172+ // The strip's sections are switches named "Chats", "Bots" (Bots may add "2 things need you").
173+ let item = app . webViews . switches . matching ( NSPredicate ( format : " label BEGINSWITH %@ " , label ) ) . firstMatch
171174 guard item . waitForExistence ( timeout : 10 ) else { return false }
172175 sleep ( 1 )
173176 item . tap ( )
@@ -212,16 +215,15 @@ final class WebNavUITests: ShellTestCase {
212215 var account = accountButton ( app )
213216 XCTAssertNotNil ( account , " no account button in the drawer " )
214217 account ? . tap ( )
215- let settings = app . webViews . descendants ( matching : . any ) . matching ( NSPredicate ( format : " label == 'Settings' " ) ) . firstMatch
216- if settings . waitForExistence ( timeout : 8 ) {
218+ if let settings = firstExisting ( [ app . webViews . menuItems [ " Settings " ] , app . webViews . buttons [ " Settings " ] , app . webViews . links [ " Settings " ] ] , timeout : 8 ) {
217219 settings . tap ( )
218220 sleep ( 3 )
219221 screenshot ( " tour-settings " )
220222 }
221223
222224 account = accountButton ( app )
223225 account ? . tap ( )
224- let signOut = firstExisting ( [ webElement ( app , label : " Sign out " ) , webText ( app , " Sign out " ) ] , timeout : 10 )
226+ let signOut = firstExisting ( [ app . webViews . menuItems [ " Sign out " ] , app . webViews . buttons [ " Sign out " ] ] , timeout : 10 )
225227 XCTAssertNotNil ( signOut , " the Account menu has no Sign out " )
226228 sleep ( 1 )
227229 signOut ? . tap ( )
0 commit comments