5

Im getting this error on the Unit Test:

No matches found for Find: Elements matching predicate '"addressSearchBar" IN identifiers' from input {(
    SearchField, 0x60000038a420, traits: 146029151232, label: 'Search on Google Maps', placeholderValue: 'Search on Google Maps'
)}

This the unit Test:

func testTypeSearch() {
    app.searchFields["addressSearchBar"].typeText("Springfield")
}

Ive been looking at this post: Xcode UITest sometimes does not find property of XCUIElement

And Ive set isAccessibilityElement

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
    view.isAccessibilityElement = false
    view.backgroundColor = UIColor.white
    navigationController?.setNavigationBarHidden(true, animated: true)
}

and here:

searchBar = UISearchBar()
searchBar.isAccessibilityElement = false
searchBar.accessibilityIdentifier = "addressSearchBar"

I've tried multiple solutions and I didn't manage to solve the problem.

Tassio Marques
  • 81
  • 1
  • 10

1 Answers1

0

can try accessibility property set to true

The default value for this property is false unless the receiver is a standard UIKit control, in which case the value is true.

searchBar = UISearchBar()
searchBar.isAccessibilityElement = true
searchBar.accessibilityIdentifier = "addressSearchBar"