Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add support to send flutterSystemPort from capabilities and update th… #14

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

saikrishna321 marked this conversation as resolved.
Show resolved Hide resolved

## Install the Flutter Integration Driver

```bash
Expand Down
3 changes: 3 additions & 0 deletions src/desiredCaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ export const desiredCapConstraints = {
},
flutterServerLaunchTimeout: {
isNumber: true,
},
flutterSystemPort: {
isNumber: true,
}
} as const;
15 changes: 7 additions & 8 deletions src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,17 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
portReleaseCallback: iosRemovePortForward,
};
}

const flutterCaps: DriverCaps<FlutterDriverConstraints> = {
flutterServerLaunchTimeout: this.internalCaps.flutterServerLaunchTimeout || 5000,
flutterSystemPort: this.internalCaps.flutterSystemPort || await getFreePort(),
} as DriverCaps<FlutterDriverConstraints>;
const systemPort =
this.proxydriver instanceof XCUITestDriver &&
!this.proxydriver.isRealDevice()
? null
: await getFreePort();
: flutterCaps.flutterSystemPort!;

const udid = this.proxydriver.opts.udid!;

const flutterCaps: DriverCaps<FlutterDriverConstraints> = {
flutterServerLaunchTimeout: this.internalCaps.flutterServerLaunchTimeout || 5000
} as DriverCaps<FlutterDriverConstraints>;
this.flutterPort = await fetchFlutterServerPort({
udid,
packageName,
Expand All @@ -263,8 +262,8 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
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.`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export async function fetchFlutterServerPort({
flutterCaps
}: {
udid: string;
systemPort?: number;
systemPort?: number | null;
portForwardCallback?: (
udid: string,
systemPort: number,
Expand Down
Loading