patrol
patrol copied to clipboard
Native Automator Not Working
Steps to reproduce
- Native automator not working
Actual results
This is my Source Code
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:krishokbd/config/di/dependency_injector.dart';
import 'package:nb_utils/nb_utils.dart';
import 'package:path_provider/path_provider.dart';
import 'package:patrol/patrol.dart';
import 'package:krishokbd/main.dart' as app;
Future<void> main() async {
const nativeConfig = NativeAutomatorConfig(
packageName: 'com.krishokbd.app',
androidAppName: '[QA] Krishik BD',
bundleId: "com.example.krishokbd",
);
patrolTest(
"Automation Testing",
nativeAutomation: true,
bindingType: BindingType.integrationTest,
config: const PatrolTesterConfig(),
nativeAutomatorConfig: nativeConfig,
($) async {
await configureDependencies();
// App Language List
await initialize();
defaultToastGravityGlobal = ToastGravity.BOTTOM;
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: await getApplicationDocumentsDirectory(),
);
await $.pumpWidgetAndSettle(const app.MyApp());
await $.pumpAndSettle();
await Future.delayed(const Duration(seconds: 3));
await $.native.disableWifi();
// await $.nativeAutomator?.pressBack();
//
await Future.delayed(const Duration(seconds: 10));
},
);
}
I've also setup up native android setting and add this setting in pubspec.yaml
patrol:
app_name: Krishokbd
android:
package_name: com.krishokbd.app
ios:
bundle_id: com.example.krishokbd
But unfortunately native and the nativeAutomator not working I've also try with patrol test --target integration_test/automation_test.dart it's generate a file named as test_bundle.dart
final binding = PatrolBinding.ensureInitialized(NativeAutomatorConfig());
this line throw an error too many positional argument
if i modify this line with
final binding = PatrolBinding.ensureInitialized();
Then throw new error
Exception has occurred.
SocketException (SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 45160)
I've already spend too much time to figure out actual problem and run the automator. Without the native task it's work fine. if it works fine without native automate then what's the point. If i wrong in my code or process then please guide me .
Logs
Logs
Exception has occurred.
_AssertionError ('package:patrol/src/custom_finders/patrol_integration_tester.dart': Failed assertion: line 33 pos 7: 'nativeAutomator != null': NativeAutomator is not initialized. Make sure you passed `nativeAutomation: true` to patrolTest(), and that you're *not* initializing any bindings in your test.)
Patrol version
patrol: ^2.3.2
Patrol Doctor output
Patrol Doctor output
Program adb found in /usr/local/bin/adb
Env var $ANDROID_HOME set to /usr/local/opt/ruby/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/pp/dev/flutter/bin/:/usr/local/opt/ruby/bin:/Users/pp/dev/flutter/bin:/Users/pp/.pub-cache/bin://usr/local/bin/code:/Users/pp/dev/flutter/bin:/Users/pp/.pub-cache/bin:/Users/pp/dev/flutter/bin://usr/local/bin/code:/Users/pp/.pub-cache/bin:/usr/local/bin/adb
Program xcodebuild found in /usr/bin/xcodebuild
Program ideviceinstaller found in /usr/local/bin/ideviceinstaller
Flutter Doctor output
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.9, on macOS 14.1.2 23B92 darwin-x64, locale en-BD)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.84.1)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!
Hi @Muhammad-Sharif-Ullah , it looks like a mismatch between CLI and patrol package versions. Which version of the patrol_cli and patrol are you using?
Hi @Muhammad-Sharif-Ullah , it looks like a mismatch between CLI and patrol package versions. Which version of the patrol_cli and patrol are you using?
patrol_cli: 2.2.0 patrol 3.3.0
Thanks for a quick response. If you use patrol >=3.0.0, then you have to use patrol_cli >= 2.3.0. See here: https://pub.dev/packages/patrol/changelog#300. Let me know if it helped
I am getting similar like this, and I am running
patrol: ^2.3.2
patrol_cli v2.3.0
@cheuk0324 those versions don't match - check the changelog (https://pub.dev/packages/patrol/changelog) to find out which version you need
After upgrading the version now it's working on android, I finally can run the test, but didn't tried it in IOS yet , will soon. Previously I tried these version
patrol : 2.3.0 patrol_cli v2.2.0
Test start initially but after sometime giving android native side error , i kept same configuration for android which I applied in
patrol_cli: 2.2.0
patrol 3.3.0.
Moreover new version works fine for me, thanks you @jBorkowska for your feed back. And thanks the "Patrol" team for this awesome testing tools
I'm using latest patrol and patrol_cli versions
patrol : 3.3.0 patrol_cli: 2.5.0 flutter: 3.16.5
and I'm still getting this error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ClientException with SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 57052, uri=http://localhost:8081/initialize
from this line in test_bundle.dart
await nativeAutomator.initialize();
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Vikas\user-application> flutter test integration_test/app_test.dart 00:00 +0: loading C:/Vikas/user-application/integration_test/app_test.dart R You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply
You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply
Note: C:\Users\VikasPShetty\AppData\Local\Pub\Cache\hosted\pub.dev\contacts_service-0.6.3\android\src\main\java\flutter\plugins\contactsservice\contactsservice\ContactsServicePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\VikasPShetty\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_sound_lite-8.5.0\android\src\main\java\com\dooboolab\fluttersound\FlutterSound.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 03:34 +0: loading C:/Vikas/user-application/integration_test/app_test.dart 214.3s √ Built build\app\outputs\flutter-apk\app-debug.apk 03:37 +0: loading C:/Vikas/user-application/integration_test/app_test.dart I03:45 +0: loading C:/Vikas/user-application/integration_test/app_test.dart 7.6s Error: ADB exited with exit code 1 Performing Streamed Install
adb: failed to install C:\Vikas\user-application\build\app\outputs\flutter-apk\app-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.qiki.qiki
signatures do not match previously installed version; ignoring!]
Uninstalling old version...
03:52 +0: loading C:/Vikas/user-application/integration_test/app_test.dart 6.7s
03:57 +0: loading C:/Vikas/user-application/integration_test/app_test.dart
Patrol (native): NativeAutomatorClient created, port: 8081
Patrol (native): NativeAutomatorClient created, port: 8081
03:57 +0 -1: loading C:/Vikas/user-application/integration_test/app_test.dart [E]
Failed to load "C:/Vikas/user-application/integration_test/app_test.dart": 'package:flutter/src/foundation/binding.dart': Failed assertion: line 153 pos 12: '_debugInitializedType == null': Binding is already initialized to IntegrationTestWidgetsFlutterBinding
dart:core _AssertionError._throwNew
package:flutter/src/foundation/binding.dart 153:12 new BindingBase
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding&Semanti package:patrol/src/common.dart 93:39 patrolTest
c:/Vikas/user-application/integration_test/app_test.dart 44:3 main
To run this test again: C:\Flutter_SDK\flutter\bin\cache\dart-sdk\bin\dart.exe test C:/Vikas/user-application/integration_test/app_test.dart -p vm --plain-name "loading C:/Vikas/user-application/integration_test/app_test.dart" 03:57 +0 -1: Some tests failed. PS C:\Vikas\user-application> flutter test integration_test/app_test.dart 00:00 +0: loading C:/Vikas/user-application/integration_test/app_test.dart RYou are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply
You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply
01:48 +0: loading C:/Vikas/user-application/integration_test/app_test.dart 108.0s √ Built build\app\outputs\flutter-apk\app-debug.apk 01:52 +0: loading C:/Vikas/user-application/integration_test/app_test.dart I01:59 +0: loading C:/Vikas/user-application/integration_test/app_test.dart 7.0s Error: ADB exited with exit code 1 Performing Streamed Install
adb: failed to install C:\Vikas\user-application\build\app\outputs\flutter-apk\app-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.qiki.qiki
signatures do not match previously installed version; ignoring!]
Uninstalling old version...
02:00 +0: loading C:/Vikas/user-application/integration_test/app_test.dart I02:07 +0: loading C:/Vikas/user-application/integration_test/app_test.dart 6.8s
02:11 +0: loading C:/Vikas/user-application/integration_test/app_test.dart
Patrol (native): NativeAutomatorClient created, port: 8081
Patrol (native): NativeAutomatorClient created, port: 8081
02:11 +0 -1: loading C:/Vikas/user-application/integration_test/app_test.dart [E]
Failed to load "C:/Vikas/user-application/integration_test/app_test.dart": 'package:flutter/src/foundation/binding.dart': Failed assertion: line 153 pos 12: '_debugInitializedType == null': Binding is already initialized to IntegrationTestWidgetsFlutterBinding
dart:core _AssertionError._throwNew
package:flutter/src/foundation/binding.dart 153:12 new BindingBase
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding&SemanticsBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding&SemanticsBinding&RendererBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding&SemanticsBinding&RendererBinding&PaintingBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding&SemanticsBinding&RendererBinding&PaintingBinding&WidgetsBinding
package:flutter_test/src/binding.dart new _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding&ServicesBinding&GestureBinding&SemanticsBinding&RendererBinding&PaintingBinding&WidgetsBinding&TestDefaultBinaryMessengerBinding
package:flutter_test/src/binding.dart new TestWidgetsFlutterBinding
package:flutter_test/src/binding.dart new LiveTestWidgetsFlutterBinding
package:patrol/src/binding.dart new PatrolBinding
package:patrol/src/binding.dart 125:7 new PatrolBinding.ensureInitialized
package:patrol/src/common.dart 93:39 patrolTest
c:/Vikas/user-application/integration_test/app_test.dart 44:3 main
To run this test again: C:\Flutter_SDK\flutter\bin\cache\dart-sdk\bin\dart.exe test C:/Vikas/user-application/integration_test/app_test.dart -p vm --plain-name "loading C:/Vikas/user-application/integration_test/app_test.dart" 02:11 +0 -1: Some tests failed. I DONT UNDERSTAND THIS ISSUE? CAN YOU RESOLVE THIS..
I am also getting same issue .Did anyone find the solution?