From a9c0c22cbf8c59fdf7ea8f817e39435bb3576125 Mon Sep 17 00:00:00 2001 From: saikrishna321 Date: Mon, 17 Jun 2024 18:00:23 +0530 Subject: [PATCH 1/3] add support to send flutterSystemPort from capabilities and update the documentation --- README.md | 22 +++++++++++++++++++++- src/desiredCaps.ts | 3 +++ src/driver.ts | 15 +++++++-------- src/utils.ts | 2 +- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6361e93..2021488 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This driver is built using [Flutter Integration Test](https://docs.flutter.dev/c ```yaml dev_dependencies: - appium_flutter_server: ^0.0.4 + appium_flutter_server: ^0.0.7 ``` 2. Create a directory called `integration_test` in the root of your Flutter project. @@ -76,6 +76,26 @@ This driver is built using [Flutter Integration Test](https://docs.flutter.dev/c Bingo! You are ready to run your tests using Appium Flutter Integration Driver. +Check if your Flutter app is running on the device or emulator. + +For Android +``` +1. Run adb command `adb logcat | grep flutter` to check if the Flutter app is running. +2. Open the application in the device or emulator manually. +3. Verify the logs in the console. +``` +``` +06-17 17:02:13.246 32697 32743 I flutter : The Dart VM service is listening on http://127.0.0.1:33339/E2REX61NaiI=/ +06-17 17:02:13.584 32697 32735 I flutter : 00:00 +0: appium flutter server +06-17 17:02:14.814 32697 32735 I flutter : shelfRun HTTP service running on port 9000 +06-17 17:02:14.814 32697 32735 I flutter : [APPIUM FLUTTER] Appium flutter server is listening on port 9000 +06-17 17:02:14.866 32697 32735 I flutter : [APPIUM FLUTTER] New Request [GET] http://127.0.0.1:10000/status +06-17 17:02:14.869 32697 32735 I flutter : [APPIUM FLUTTER] response {message: Flutter driver is ready to accept new connections, appInfo: {appName: appium_testing_app, buildNumber: 1, packageName: com.example.appium_testing_app, version: 1.0.0, buildSignature: F2C7CEC8F907AB830B7802C2178515D1FD4BEBA154E981FB61FFC8EC9A8F8195}} +``` + +For iOS + + ## Install the Flutter Integration Driver ```bash diff --git a/src/desiredCaps.ts b/src/desiredCaps.ts index 687f1ff..200099d 100644 --- a/src/desiredCaps.ts +++ b/src/desiredCaps.ts @@ -19,5 +19,8 @@ export const desiredCapConstraints = { }, flutterServerLaunchTimeout: { isNumber: true, + }, + flutterSystemPort: { + isNumber: true, } } as const; diff --git a/src/driver.ts b/src/driver.ts index cd1a9e1..bebd44a 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -240,18 +240,17 @@ export class AppiumFlutterDriver extends BaseDriver { portReleaseCallback: iosRemovePortForward, }; } - + const flutterCaps: DriverCaps = { + flutterServerLaunchTimeout: this.internalCaps.flutterServerLaunchTimeout || 5000, + flutterSystemPort: this.internalCaps.flutterSystemPort || await getFreePort(), + } as DriverCaps; const systemPort = this.proxydriver instanceof XCUITestDriver && !this.proxydriver.isRealDevice() ? null - : await getFreePort(); + : flutterCaps.flutterSystemPort!; const udid = this.proxydriver.opts.udid!; - - const flutterCaps: DriverCaps = { - flutterServerLaunchTimeout: this.internalCaps.flutterServerLaunchTimeout || 5000 - } as DriverCaps; this.flutterPort = await fetchFlutterServerPort({ udid, packageName, @@ -263,8 +262,8 @@ export class AppiumFlutterDriver extends BaseDriver { if (!this.flutterPort) { throw new Error( `Flutter server is not started. ` + - `Please make sure the application under test is configured properly according to ` + - `https://github.com/AppiumTestDistribution/appium-flutter-server and that it does not crash on startup.`, + `Please make sure the application under test is configured properly.Please refer ` + + `https://github.com/AppiumTestDistribution/appium-flutter-integration-driver?tab=readme-ov-file#how-to-use-appium-flutter-integration-driver.`, ); } diff --git a/src/utils.ts b/src/utils.ts index ca1661d..f94836e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -97,7 +97,7 @@ export async function fetchFlutterServerPort({ flutterCaps }: { udid: string; - systemPort?: number; + systemPort?: number | null; portForwardCallback?: ( udid: string, systemPort: number, From 2b488f38d61137e9a842319a1bdd51caf552cb30 Mon Sep 17 00:00:00 2001 From: saikrishna321 Date: Mon, 17 Jun 2024 18:05:03 +0530 Subject: [PATCH 2/3] updated readMe under capabilities --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2021488..164d5d7 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,10 @@ For more details, refer to the documentation for each driver: ## Capabilities for Appium Flutter Integration Driver -| Capability | Description | Required | -| ------------------------- |-------------------------------------------------------------------------| -------- | +| Capability | Description | Required | +|----------------------------------|-------------------------------------------------------------------------|----------| | appium:flutterServerLaunchTimeout | Time in ms to wait for flutter server to be pingable. Default is 5000ms | No | +| appium:flutterSystemPort | The number of the port on the host machine used for the Flutter server. By default the first free port from 10000..11000 range is selected. It is recommended to set this value if you are running parallel tests on the same machine.| No | ## Locating Elements From 2399e426047ec1e4a666300edaaaad32330977b7 Mon Sep 17 00:00:00 2001 From: saikrishna321 Date: Tue, 18 Jun 2024 17:39:32 +0530 Subject: [PATCH 3/3] updated readMe --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 164d5d7..5880b0b 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,20 @@ For Android ``` For iOS +Simulator: +```xcrun simctl spawn booted log stream | grep flutter``` + +Real Device: Check xcode device logs. + +2. Open the application in the device or emulator manually. +``` +06-17 17:02:13.246 32697 32743 I flutter : The Dart VM service is listening on http://127.0.0.1:33339/E2REX61NaiI=/ +06-17 17:02:13.584 32697 32735 I flutter : 00:00 +0: appium flutter server +06-17 17:02:14.814 32697 32735 I flutter : shelfRun HTTP service running on port 9000 +06-17 17:02:14.814 32697 32735 I flutter : [APPIUM FLUTTER] Appium flutter server is listening on port 9000 +06-17 17:02:14.866 32697 32735 I flutter : [APPIUM FLUTTER] New Request [GET] http://127.0.0.1:10000/status +06-17 ## Install the Flutter Integration Driver