Facebook WebDriverAgent Python Client

1.5.4 · active · verified Thu Apr 16

facebook-wda is a Python client library for Facebook's WebDriverAgent, an iOS test automation framework that enables UI testing and remote control of iOS devices and simulators. It provides a programmatic interface to interact with iOS applications, perform gestures, take screenshots, and manage app states. The library is actively maintained, with frequent releases, and is currently at version 1.5.4.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the facebook-wda client, check the WebDriverAgent's status, simulate a home button press, launch an application (Safari), navigate to a URL, and capture a screenshot. It uses an environment variable for the WDA URL for flexibility.

import wda
import os

# Get WDA server URL from environment variable, default to localhost
# Ensure WebDriverAgent is running on your iOS device/simulator, e.g., via Xcode or another tool.
wda_url = os.environ.get('WDA_URL', 'http://localhost:8100')
c = wda.Client(wda_url)

print(f"Connecting to WDA at: {wda_url}")
try:
    status = c.status()
    print(f"WDA Status: {status['state']}")

    # Example: Press home button
    c.home()

    # Example: Start a session with an app (e.g., Safari)
    with c.session('com.apple.mobilesafari') as s:
        print(f"Session orientation: {s.orientation}")
        print(f"Window size (UIKit points): {s.window_size()}")
        s.open_url("https://www.google.com")
        # Take a screenshot (requires Pillow to save to file)
        s.screenshot('safari_screen.png')
        print("Screenshot saved to safari_screen.png")
except wda.WDAError as e:
    print(f"Failed to connect or interact with WDA: {e}")
    print("Ensure WebDriverAgent is running and accessible at the specified URL.")

view raw JSON →