diff --git a/README.md b/README.md index 6361e93..5880b0b 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,39 @@ 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 +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 ```bash @@ -95,9 +128,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 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,