Foti Dim
Foti Dim

Reputation: 1371

UI Testing failure - No matches found for SearchField

My XCode recorded UI test fails on the second line:

XCUIElement *musicselectviewNavigationBar = app.navigationBars[@"MusicSelectView"];
[[musicselectviewNavigationBar.otherElements childrenMatchingType:XCUIElementTypeSearchField].element tap];
[[musicselectviewNavigationBar.searchFields containingType:XCUIElementTypeButton identifier:@"Clear text"].element typeText:@"Lean"];

Upon testing I get this error:

UI Testing failure - No matches found for "MusicSelectView" NavigationBar

Ideas?

Upvotes: 1

Views: 3876

Answers (2)

Oleg Shanyuk
Oleg Shanyuk

Reputation: 1336

  1. check what you have at line 1 in app.navigationBars
  2. set your navigation bar accessibilityIdentifier to @"MusicSelectView"
  3. access your navigation bar with matchingIdentifier:@"MusicSelectView" method call

Upvotes: 0

Joe Masilotti
Joe Masilotti

Reputation: 17008

Access the search bar directly instead of using the recorded path.

[app.searchFields[@"Clear text"] tap];
[app.searchFields[@"Clear text"] typeText:@"Lean"];

If there is only one search field present, you can access it with element.

[[app.searchFields element] tap];
[[app.searchFields element] typeText:@"Lean"];

Upvotes: 2

Related Questions