Check out the Patrol 4.0 release announcement for a complete overview of new features.
What’s New in Patrol 4.0
Patrol 4.0 brings several major improvements:- Web Testing Support: Test your Flutter web applications with Patrol
- Platform Automation API: Unified API replacing the legacy
nativeandnative2APIs - VS Code Extension: Enhanced development experience with debugging and test running capabilities
- New Default Test Directory: Changed from
integration_test/topatrol_test/ - Improved Device Selection: Interactive device prompts and better CI support
Breaking Changes
1. Platform Automation API
The biggest change in Patrol 4.0 is the introduction of the Platform Automation API, which replaces the legacy$.native and $.native2 entry points.
Update Selector Types
Replace After:
NativeSelector with the appropriate new selector type:MobileSelector(...)- For different Android/iOS selectorsSelector(...)- For same selector across platformsPlatformSelector(...)- For Android/iOS/Web selectors
2. Test Directory Change
3. Device Selection Changes
Patrol 4.x now prompts for device selection interactively. This improves the development experience but requires changes in CI environments.When
CI=true is set, Patrol will automatically select an available device without prompting.Migration Checklist
Use this checklist to ensure a smooth migration:Update Native Automation Calls
Search and replace across your test files:
$.native.→$.platform.mobile.or$.platform.android./$.platform.ios.$.native2.→$.platform.mobile.NativeSelector→MobileSelector,Selector, orPlatformSelectorNativeAutomator→PlatformAutomatorNativeAutomatorConfig→PlatformAutomatorConfig
Update CI Configuration
Add
--device flag or set CI=true in your CI pipeline:.github/workflows/test.yml
Common Migration Patterns
Permission Handling
Notification Handling
Device Settings
Navigation
New Features in Patrol 4.0
Web Support
Patrol 4.0 introduces comprehensive web testing capabilities:Learn more about web testing with Patrol.
PlatformSelector for Multi-Platform Tests
Write tests that work across mobile and web:VS Code Extension
The new Patrol VS Code extension provides:- Run and debug tests directly from VS Code
- Test exploration and navigation
- Real-time test results
- Integration with Flutter DevTools
Learn more about the Patrol VS Code Extension.
Troubleshooting
Tests Fail After Migration
If your tests fail after migration, check:- Correct namespace: Ensure platform-specific actions use the right namespace (
$.platform.android.*vs$.platform.ios.*) - Selector types: Verify you’re using the correct selector type for your use case
- Configuration: Check that
PlatformAutomatorConfigis properly initialized
Deprecation Warnings
If you see deprecation warnings:Device Selection Issues in CI
If CI fails with device selection prompts:Need Help?
If you encounter issues during migration:- Check the Native to Platform Migration Guide for detailed API changes
- Visit our GitHub repository to report issues
- Join our Discord community for support
Next Steps
After completing the migration:- Explore web testing capabilities
- Try the VS Code Extension
- Learn about advanced platform automation
- Review best practices