Marionette
Marionette 是一个 Swift 库,提供了一个高级 API 来控制 WKWebView。
目标是让 API 与 Puppeteer 非常相似。
安装
SwiftPM
dependencies: [
.package(url: "https://github.com/LinusU/Marionette", from: "1.0.0"),
]
Carthage
github "LinusU/Marionette" ~> 1.0.0
用法
let page = Marionette()
firstly {
page.goto(URL(string: "https://www.google.com/")!)
}.then {
page.type("input[name='q']", "LinusU Marionette")
}.then {
when(fulfilled: page.waitForNavigation(), page.click("input[type='submit']"))
}.then {
page.screenshot()
}.done {
print("Screenshot of Google results: \($0)")
}
黑客攻击
使用 XcodeGen 将自动从 project.yml
生成 Xcode 项目。因为它被 Carthage 需要而提交,请勿手动编辑。
$ mint run yonaskolb/xcodegen
💾 Saved project to Marionette.xcodeproj