问题
Create a new Swift Xcode Single view project with UI test target.
In Main.storyboard select ViewController, then Editor/Embed in/Navigation Controller.
Change ViewController.swift
to the following code:
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate
{
var _webView: WKWebView!
override func loadView() {
_webView = WKWebView()
_webView.navigationDelegate = self
view = _webView
}
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://www.google.com")!
_webView.load(URLRequest(url: url))
_webView.allowsBackForwardNavigationGestures = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
In the generated UI test class (that extends from XCTestCase
) position cursor in func testExample()
body, hit the red record button.
Wait until the web view loaded the webpage.
Click inside the webview.
KABOOM! Xcode crashes!
Anyone have any solution for this? It's a game stopper for our UI test pipeline.
来源:https://stackoverflow.com/questions/50442216/xctest-xcode-crashing-when-trying-to-record-elements-inside-wkwebview