Marionette for Flutter

Marionette is a library which provides a high-level API to control a WebView.

The goal is to have the API closely mirror that of Puppeteer.

Other platforms: Swift (macOS/iOS), JavaScript (Node)


import 'package:flutter_marionette/marionette.dart';

() async {
  final page = Marionette();

  await page.goto("");
  await page.type("input[name='q']", "LinusU Marionette")
  await Future.wait([page.waitForNavigation(),"input[type='submit']")]);



To be able to use Marionette on iOS, you need to give Marionette a hook to your view hierarchy. Otherwise the WKWebView will get suspended by the OS, and your Promises will never settle.

This is accomplished by using the setGlobalUIHook function before instantiating any Marionette instances.


If you have a non-modified Flutter application, this should be added to ios/Runner/AppDelegate.swift, in the application(_:didFinishLaunchingWithOptions:) function.

--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,5 +1,6 @@
 import UIKit
 import Flutter
+import flutter_marionette

 @objc class AppDelegate: FlutterAppDelegate {
   override func application(
     _ application: UIApplication,
     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
   ) -> Bool {
+    SwiftFlutterMarionettePlugin.setGlobalUIHook(window:!)
     GeneratedPluginRegistrant.register(with: self)
     return super.application(application, didFinishLaunchingWithOptions: launchOptions)


// Can be called from anywhere, e.g. your AppDelegate

App Extension:

// From within your root view controller
SwiftFlutterMarionettePlugin.setGlobalUIHook(viewController: self)