NativeAutomator2 class

Provides functionality to interact with the OS that the app under test is running on.

Communicates over http with the native automation server running on the target device.

Annotations
  • @Deprecated('NativeAutomator2 is deprecated and will be removed in a future release. ' 'Please use PlatformAutomator instead.')

Constructors

NativeAutomator2({required PlatformAutomator platformAutomator})
Creates a new NativeAutomator2.

Properties

hashCode int
The hash code for this object.
no setterinherited
resolvedAppId String
Returns the platform-dependent unique identifier of the app under test.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

closeHeadsUpNotification() Future<void>
Closes the currently visible heads up notification (iOS only).
closeNotifications() Future<void>
Closes the notification shade.
denyPermission() Future<void>
Denies the permission that the currently visible native permission request dialog is asking for.
disableAirplaneMode() Future<void>
Enables airplane mode.
disableBluetooth() Future<void>
Disables bluetooth.
disableCellular() Future<void>
Disables cellular (aka mobile data connection).
disableDarkMode({String? appId}) Future<void>
Disables dark mode.
disableLocation() Future<void>
Disables location.
disableWifi() Future<void>
Disables Wi-Fi.
doubleTap(NativeSelector selector, {String? appId, Duration? timeout, Duration? delayBetweenTaps}) Future<void>
Double taps on the native view specified by selector.
enableAirplaneMode() Future<void>
Enables airplane mode.
enableBluetooth() Future<void>
Enables bluetooth.
enableCellular() Future<void>
Enables cellular (aka mobile data connection).
enableDarkMode({String? appId}) Future<void>
Enables dark mode.
enableLocation() Future<void>
Enables location.
enableWifi() Future<void>
Enables Wi-Fi.
enterText(NativeSelector selector, {required String text, String? appId, KeyboardBehavior? keyboardBehavior, Duration? timeout, Offset? tapLocation}) Future<void>
Enters text to the native view specified by selector.
enterTextByIndex(String text, {required int index, String? appId, KeyboardBehavior? keyboardBehavior, Duration? timeout, Offset? tapLocation}) Future<void>
Enters text to the index-th visible text field.
getFirstNotification() Future<Notification>
Returns the first, topmost visible notification.
getNativeViews(NativeSelector selector, {String? appId}) Future<GetNativeViewsResult>
Returns a list of currently visible native UI controls, specified by selector, which are currently visible on screen.
getNotifications() Future<List<Notification>>
Returns notifications that are visible in the notification shade.
getOsVersion() Future<int>
Gets the OS version.
grantPermissionOnlyThisTime() Future<void>
Grants the permission that the currently visible native permission request dialog is asking for.
grantPermissionWhenInUse() Future<void>
Grants the permission that the currently visible native permission request dialog is asking for.
isPermissionDialogVisible({Duration timeout = const Duration(seconds: 1)}) Future<bool>
Waits until a native permission request dialog becomes visible within timeout.
isVirtualDevice() Future<bool>
Checks if the app is running on a virtual device (simulator or emulator).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openApp({String? appId}) Future<void>
Opens the app specified by appId. If appId is null, then the app under test is started (using resolvedAppId).
openNotifications() Future<void>
Opens the notification shade.
openPlatformApp({Object? androidAppId, Object? iosAppId}) Future<void>
Opens a platform-specific app.
openQuickSettings() Future<void>
Opens the quick settings shade on Android and Control Center on iOS.
openUrl(String url) Future<void>
Opens the URL specified by url.
pickImageFromGallery({NativeSelector? imageSelector, int? index, Duration? timeout}) Future<void>
Pick an image from the gallery
pickMultipleImagesFromGallery({required List<int> imageIndexes, NativeSelector? imageSelector, Duration? timeout}) Future<void>
Pick multiple images from the gallery
pressBack() Future<void>
Presses the back button.
pressDoubleRecentApps() Future<void>
Double presses the recent apps button.
pressHome() Future<void>
Presses the home button.
pressRecentApps() Future<void>
Presses the recent apps button.
pressVolumeDown() Future<void>
Press volume down
pressVolumeUp() Future<void>
Press volume up
pullToRefresh({Offset from = const Offset(0.5, 0.5), Offset to = const Offset(0.5, 0.9), int steps = 50}) Future<void>
Simulates pull-to-refresh gesture.
selectCoarseLocation() Future<void>
Select the "coarse location" (aka "approximate") setting on the currently visible native permission request dialog.
selectFineLocation() Future<void>
Select the "fine location" (aka "precise") setting on the currently visible native permission request dialog.
setMockLocation(double latitude, double longitude, {String? packageName}) Future<void>
Set mock location
swipe({required Offset from, required Offset to, int steps = 12, String? appId, bool enablePatrolLog = true}) Future<void>
Swipes from from to to.
swipeBack({double dy = 0.5, String? appId}) Future<void>
Mimics the swipe back (left to right) gesture.
takeCameraPhoto({NativeSelector? shutterButtonSelector, NativeSelector? doneButtonSelector, Duration? timeout}) Future<void>
Take and confirm the photo
tap(NativeSelector selector, {String? appId, Duration? timeout}) Future<void>
Taps on the native view specified by selector.
tapAt(Offset location, {String? appId}) Future<void>
Taps at a given location.
tapBackToPreviousAppButton({Duration? timeout}) Future<void>
Taps on the iOS "back to previous app" breadcrumb button (iOS only).
tapOnNotificationByIndex(int index, {Duration? timeout}) Future<void>
Searches for the index-th visible notification and taps on it.
tapOnNotificationBySelector(NativeSelector selector, {Duration? timeout}) Future<void>
Taps on the visible notification using selector.
toString() String
A string representation of this object.
inherited
waitUntilVisible(NativeSelector selector, {String? appId, Duration? timeout}) Future<void>
Waits until the native view specified by selector becomes visible. It waits for the view to become visible for timeout duration. If timeout is not specified, it utilizes the NativeAutomatorConfig.findTimeout.

Operators

operator ==(Object other) bool
The equality operator.
inherited