Marionette 是一个 Swift 库,它提供了一个高级 API 来控制 WKWebView。
目标是使该 API 与 Puppeteer 的 API 密切对应。
dependencies: [
.package(url: "https://github.com/LinusU/Marionette", from: "1.0.0"),
]
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)")
}
Xcode 项目是使用 XcodeGen 从 project.yml
自动生成的。它只是为了 Carthage 需要才被检入,请不要手动编辑它。
$ mint run yonaskolb/xcodegen
💾 Saved project to Marionette.xcodeproj