title: iOS 13 Xcode UI test Automation type mismatch
body: <p>My app uses a <code>WKWebView</code> that is setup in code (this is done because of <a href="https://stackoverflow.com/a/46649435/1987726">this bug</a> in iOS 10):  </p>
  
  <pre><code>final class HelpViewController: UIViewController {
    // …
      var webView: WKWebView! 
  
    override func viewDidLoad() {
      super.viewDidLoad()
  
          let webConfiguration = WKWebViewConfiguration()
          webView = WKWebView(frame: .zero, configuration: webConfiguration)
          webView.translatesAutoresizingMaskIntoConstraints = false
          self.view.addSubview(webView)
          let margins = view.layoutMarginsGuide
          webView.topAnchor.constraint(equalTo: self.back.bottomAnchor).isActive = true
          webView.rightAnchor.constraint(equalTo: margins.rightAnchor).isActive = true
          webView.leftAnchor.constraint(equalTo: margins.leftAnchor).isActive = true
          webView.bottomAnchor.constraint(equalTo: margins.bottomAnchor).isActive = true
          webView.navigationDelegate = self
    //…
  }  
  </code></pre>
  
  <p>My UI test looks like this:  </p>
  
  <pre><code>func test_helpButtonShowsHelpText() {
    //…
      let webView = shopEasyApp.webViews.element
      let webViewExists = webView.waitForExistence(timeout: kDefaultUITestTimeout)
      XCTAssert(webViewExists, "Web view does not exist")
      let webViewIsHittable = webView.isHittable  
    //…  
    }  
  </code></pre>
  
  <p>This test run without problems up to iOS 12.  </p>
  
  <p>With iOS 13, it stops at the test <code>webView.isHittable</code> with the following error:  </p>
  
  <pre><code>Failed to get matching snapshot: Multiple matching elements found for &lt;XCUIElementQuery: 0x600000bdfbb0&gt;.  
  </code></pre>
  
  <p>The log says:  </p>
  
  <pre><code>Assertion Failure: ShopEasyBasicUITests.swift:1100: Failed to get matching snapshot: Multiple matching elements found for &lt;XCUIElementQuery: 0x600003efb4d0&gt;.
  Sparse tree of matches:
  →Application, pid: 71038, label: 'Shop Easy!'
    ↳Window, {{0.0, 0.0}, {375.0, 812.0}}
      ↳Other, {{0.0, 0.0}, {375.0, 812.0}}
        ↳Other, {{0.0, 0.0}, {375.0, 812.0}}
          ↳WebView, {{16.0, 74.0}, {343.0, 704.0}}
            ↳WebView, {{16.0, 74.0}, {343.0, 704.0}}
              ↳WebView, {{16.0, 74.0}, {343.0, 704.0}}
  Possibly caused by runtime issues:
  Automation type mismatch: computed WebView from legacy attributes vs ScrollView from modern attribute. Input attributes and values: {
      "XC_kAXXCAttributeAutomationType" = 46;
      "XC_kAXXCAttributeElementBaseType" = UIScrollView;
      "XC_kAXXCAttributeElementType" = WKScrollView;
      "XC_kAXXCAttributeTraits" = 8589934592;
  }
  Automation type mismatch: computed Other from legacy attributes vs WebView from modern attribute. Input attributes and values: {
      "XC_kAXXCAttributeAutomationType" = 58;
      "XC_kAXXCAttributeElementBaseType" = UIView;
      "XC_kAXXCAttributeElementType" = WKWebView;
      "XC_kAXXCAttributeTraits" = 146028888064;
  }
  Automation type mismatch: computed Other from legacy attributes vs WebView from modern attribute. Input attributes and values: {
      "XC_kAXXCAttributeAutomationType" = 58;
      "XC_kAXXCAttributeElementBaseType" = UIView;
      "XC_kAXXCAttributeElementType" = WKContentView;
      "XC_kAXXCAttributeTraits" = 146028888064;
  }  
  </code></pre>
  
  <p>The view hierarchy is the following:<br>
  <a href="https://i.stack.imgur.com/rUTsr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rUTsr.png" alt="enter image description here"></a>  </p>
  
  <p><strong>My questions are:</strong><br>
  What is wrong with my code, and how to do it correctly?</p>