Erik基于 WebKit 的无界面浏览器
Erik是一款基于
的无界面浏览器,可用于功能函数的测试,使用
let url = NSURL(string:"https://www.google.com")! let value = "Erik The Phantom of Opera" // visit var future: Future<Document, NSError> = Erik.visitURLFuture(url) // fill input field future = future.flatMap { document -> Future<Document, NSError> in if let input = document.querySelector("input[name='q']") { input["value"] = value } if let form = document.querySelector("form[name=\"f\"]") as? Form { form.submit() } return Erik.currentContentFuture() } // finally get final result as success or error future.onSuccess { document in // parse result } future.onFailure { error in print("\(error)") }
评论