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.
pip install facebook-wdaVerified import paths — ran on the pinned version, not inferred.
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.
Manually install and run `tidevice` (e.g., `pip install tidevice` or `brew install tidevice`) and ensure WebDriverAgent is launched on your device/simulator independently. Refer to `tidevice` documentation for its usage, or start WDA directly via Xcode.
Start WebDriverAgent via Xcode, `xcodebuild` command line, or use an external tool like `tidevice` to manage its lifecycle. Ensure WDA is accessible at the specified IP:PORT (default is `http://localhost:8100`).
Use `session.scale` to get the UIKit scale factor if you need to convert between UIKit points and native pixels for accurate element positioning or image processing.
Instead of using a callback, handle alerts explicitly using `session.alert.accept()`, `session.alert.dismiss()`, or `session.alert.click("Button Name")` within your test logic.Verify WebDriverAgent is running on the device/simulator and is accessible at the specified URL (e.g., `http://localhost:8100`). Check network connectivity and WDA logs for errors. Ensure no system pop-ups are blocking WDA startup on the device.
Inspect the current screen's UI hierarchy (e.g., using Appium Inspector or `wda.Client().screenshot()`) to verify the element's presence and its attributes. Adjust element locators for accuracy or increase the wait timeout for the element. Use `.exists` for conditional checks or `.wait()` with a timeout.
This is typically a WDA or iOS-level issue rather than a `facebook-wda` library issue. Try restarting WebDriverAgent, the device/simulator, or updating WDA. Check if the error is reproducible with different WDA versions or on a different device.
Catch this exception and re-establish a new session. It's good practice to wrap operations in `try...except wda.WDAError` blocks to handle such transient failures gracefully.