2 Replies
      Latest reply on Oct 29, 2019 6:31 AM by eskimo
      fdsafasdfdas Level 1 Level 1 (0 points)

        Our app has a UISearchBar as part of a UINavigationItem's titleView.

         

        The element layout looks like this:

         

            Window (Main), 0x600001ab6060, {{0.0, 0.0}, {414.0, 896.0}}
              Other, 0x600001ab6140, {{0.0, 0.0}, {414.0, 896.0}}
                Other, 0x600001ab5ea0, {{0.0, 0.0}, {414.0, 896.0}}
                  Other, 0x600001ab5f80, {{0.0, 0.0}, {414.0, 896.0}}
                    Other, 0x600001ab5ce0, {{0.0, 0.0}, {414.0, 896.0}}
                      Other, 0x600001ab5dc0, {{0.0, 0.0}, {414.0, 896.0}}
                        Other, 0x600001ab5b20, {{0.0, 0.0}, {414.0, 896.0}}
                          NavigationBar, 0x600001ab5c00, {{0.0, 44.0}, {414.0, 56.0}}, identifier: 'Search'
                            SearchField, 0x600001ab5960, {{0.0, 44.0}, {414.0, 56.0}}, identifier: 'searchTextField'
        
        

         

        The SearchField is accessible but sending `typeText` doesn't do anything. It prints this error on console.

         

            t =    82.89s             Failed: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: SearchField, identifier: 'searchTextField'
        
        

         

        The keyboard is open before sending typeText so i've no idea what's going on here. I tried using the Record feature to see what Apple does. Taping the Search bar with Record button causes it to crash with error

        Timestamped Event Matching Error: Failed to find matching element
        
        

         

        The implementation looks like this

                navigationController?.navigationBar.isAccessibilityElement = false
                navigationItem.isAccessibilityElement = false
                searchBar.isAccessibilityElement = true
        
                searchBar.accessibilityIdentifier = "searchTextField"
                searchBar.accessibilityTraits = [.searchField]
                navigationItem.titleView = searchBar