device.routeTraffic() sets up a per-app VPN on the test device that intercepts and redirects network traffic before your test runs. You can target specific apps by bundle ID, or limit routing to specific domains when testing with Safari.
Call
device.routeTraffic() before starting your WebDriver session so the tunnel is active from the first network request.Examples
Route a native app’s traffic (all traffic from the app is intercepted):When to use
- Your app connects to internal or staging services that aren’t publicly accessible.
- You need to test geo-restricted content by routing through a VPN endpoint in a specific region.
- You want to verify how your app behaves when traffic passes through a proxy (authentication, filtering, latency).
- You need to test Safari against specific internal domains without affecting other browsing.
Tunnel types
Choose a tunnel type based on how your network is set up.WireGuard
Use if your team already has a WireGuard VPN or you need to simulate traffic from a specific geographic region.OpenVPN
Use if your organization uses a standard VPN setup with.ovpn config files.