Skip to content

Commit 73f05af

Browse files
add appium:address capabaility
* add appium:address capabaility * Fix readme * fix
1 parent 93f6d6c commit 73f05af

File tree

6 files changed

+78
-53
lines changed

6 files changed

+78
-53
lines changed

README.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The current Appium Flutter Driver is built on top of the `flutter_test` SDK, whi
2525

2626
This driver is built using [Flutter Integration Test](https://docs.flutter.dev/cookbook/testing/integration/introduction).
2727

28-
:star: **⁠Strong Typing & Fluent APIs:** Ensures robust and easy-to-use interfaces.
28+
:star: **⁠Strong Typing & Fluent APIs**: Ensures robust and easy-to-use interfaces.
2929

3030
:star: **⁠Element Handling**: Automatically waits for elements to attach to the DOM before interacting.
3131

@@ -35,7 +35,7 @@ This driver is built using [Flutter Integration Test](https://docs.flutter.dev/c
3535

3636
:star: **Simplified Powerful Gestures**: Supports powerful yet simplified gestures like LongPress, ScrollToElement, DragAndDrop, and DoubleClick.
3737

38-
:star:**Element Chaining**: Allows chaining of elements, enabling you to find child elements under a specific parent easily.
38+
:star: **Element Chaining**: Allows chaining of elements, enabling you to find child elements under a specific parent easily.
3939

4040
## How to Use Appium Flutter Integration Driver
4141

@@ -60,7 +60,9 @@ This driver is built using [Flutter Integration Test](https://docs.flutter.dev/c
6060
initializeTest(app: const MyApp());
6161
}
6262
```
63+
6364
If you are in need to configure certain prerequists before the testing app is loaded, you can try the following code:
65+
6466
```dart
6567
import 'package:appium_testing_app/main.dart'; as app;
6668
void main() {
@@ -91,11 +93,11 @@ Bingo! You are ready to run your tests using Appium Flutter Integration Driver.
9193
Check if your Flutter app is running on the device or emulator.
9294
9395
For Android
94-
```
96+
9597
1. Run adb command `adb logcat | grep flutter` to check if the Flutter app is running.
9698
2. Open the application in the device or emulator manually.
9799
3. Verify the logs in the console.
98-
```
100+
99101
```
100102
06-17 17:02:13.246 32697 32743 I flutter : The Dart VM service is listening on http://127.0.0.1:33339/E2REX61NaiI=/
101103
06-17 17:02:13.584 32697 32735 I flutter : 00:00 +0: appium flutter server
@@ -108,18 +110,20 @@ For Android
108110
For iOS
109111
Simulator:
110112
111-
```xcrun simctl spawn booted log stream | grep flutter```
113+
`xcrun simctl spawn booted log stream | grep flutter`
112114
113115
Real Device: Check xcode device logs.
114116
115117
2. Open the application in the device or emulator manually.
118+
116119
```
117120
06-17 17:02:13.246 32697 32743 I flutter : The Dart VM service is listening on http://127.0.0.1:33339/E2REX61NaiI=/
118121
06-17 17:02:13.584 32697 32735 I flutter : 00:00 +0: appium flutter server
119122
06-17 17:02:14.814 32697 32735 I flutter : shelfRun HTTP service running on port 9000
120123
06-17 17:02:14.814 32697 32735 I flutter : [APPIUM FLUTTER] Appium flutter server is listening on port 9000
121124
06-17 17:02:14.866 32697 32735 I flutter : [APPIUM FLUTTER] New Request [GET] http://127.0.0.1:10000/status
122125
06-17
126+
```
123127
124128
## Install the Flutter Integration Driver
125129
@@ -140,30 +144,30 @@ For more details, refer to the documentation for each driver:
140144

141145
## Capabilities for Appium Flutter Integration Driver
142146

143-
| Capability | Description | Required |
144-
|----------------------------------|-------------------------------------------------------------------------|----------|
145-
| appium:flutterServerLaunchTimeout | Time in ms to wait for flutter server to be pingable. Default is 5000ms | No |
146-
| 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 |
147-
147+
| Capability | Description | Required |
148+
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
149+
| appium:flutterServerLaunchTimeout | Time in ms to wait for flutter server to be pingable. Default is 5000ms | No |
150+
| 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 |
151+
| appium:address | Address to connect with flutter server | No |
148152

149153
## Locating Elements
150154

151155
You can use the following locators to find elements in your Flutter app. Custom finders are built for WDIO. Refer to the [wdio-flutter-by-service](https://www.npmjs.com/package/wdio-flutter-by-service?activeTab=readme).
152156

153-
| Locator | Description |
154-
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
155-
| `flutterByValueKey(value: string): Flutter.Locator` | Locate by value key |
156-
| `flutterByValueKey$(value: string): WebdriverIO.Element` | Locate single element by value key |
157-
| `flutterByValueKey$$(value: string): WebdriverIO.Element[]` | Locate multiple elements by value key |
158-
| `flutterBySemanticsLabel(label: string): Flutter.Locator` | Locate by semantics label |
159-
| `flutterBySemanticsLabel$(label: string): WebdriverIO.Element` | Locate single element by semantics label |
160-
| `flutterBySemanticsLabel$$(label: string): WebdriverIO.Element[]` | Locate multiple elements by semantics label |
161-
| `flutterByText(text: string): Flutter.Locator` | Locate by text |
162-
| `flutterByText$(text: string): WebdriverIO.Element` | Locate single element by text |
163-
| `flutterByType$(text: string): WebdriverIO.Element` | Locate single element by Type(Checkbox, RadioButton, ListView) |
164-
| `flutterByType$$(text: string): WebdriverIO.Element[]` | Locate multiple elements by text(Checkbox, RadioButton, ListView)|
165-
| `flutterDoubleClick(element: WebdriverIO.Element): WebdriverIO.Element` | Double click on an element |
166-
| `flutterWaitForAbsent(options: { element: WebdriverIO.Element; locator: Flutter.Locator; }): void` | Wait for an element to be absent |
167-
| `flutterScrollTillVisible(options: { finder: WebdriverIO.Element; scrollView?: WebdriverIO.Element; scrollDirection?: 'up','right','down','left'; delta?: number; maxScrolls?: number; settleBetweenScrollsTimeout?: number; dragDuration?: number; }): Promise<WebdriverIO.Element>` | Scroll until an element is visible |
157+
| Locator | Description |
158+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
159+
| `flutterByValueKey(value: string): Flutter.Locator` | Locate by value key |
160+
| `flutterByValueKey$(value: string): WebdriverIO.Element` | Locate single element by value key |
161+
| `flutterByValueKey$$(value: string): WebdriverIO.Element[]` | Locate multiple elements by value key |
162+
| `flutterBySemanticsLabel(label: string): Flutter.Locator` | Locate by semantics label |
163+
| `flutterBySemanticsLabel$(label: string): WebdriverIO.Element` | Locate single element by semantics label |
164+
| `flutterBySemanticsLabel$$(label: string): WebdriverIO.Element[]` | Locate multiple elements by semantics label |
165+
| `flutterByText(text: string): Flutter.Locator` | Locate by text |
166+
| `flutterByText$(text: string): WebdriverIO.Element` | Locate single element by text |
167+
| `flutterByType$(text: string): WebdriverIO.Element` | Locate single element by Type(Checkbox, RadioButton, ListView) |
168+
| `flutterByType$$(text: string): WebdriverIO.Element[]` | Locate multiple elements by text(Checkbox, RadioButton, ListView) |
169+
| `flutterDoubleClick(element: WebdriverIO.Element): WebdriverIO.Element` | Double click on an element |
170+
| `flutterWaitForAbsent(options: { element: WebdriverIO.Element; locator: Flutter.Locator; }): void` | Wait for an element to be absent |
171+
| `flutterScrollTillVisible(options: { finder: WebdriverIO.Element; scrollView?: WebdriverIO.Element; scrollDirection?: 'up','right','down','left'; delta?: number; maxScrolls?: number; settleBetweenScrollsTimeout?: number; dragDuration?: number; }): Promise<WebdriverIO.Element>` | Scroll until an element is visible |
168172

169173
For more examples, see the [test file](https://github.com/AppiumTestDistribution/appium-flutter-integration-driver/blob/main/test/specs/test.e2e.js).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"appium",
66
"flutter"
77
],
8-
"version": "1.0.0-beta.14",
8+
"version": "1.0.0-beta.15",
99
"author": "",
1010
"license": "MIT License",
1111
"repository": {

src/desiredCaps.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ export const desiredCapConstraints = {
2222
},
2323
flutterSystemPort: {
2424
isNumber: true,
25-
}
25+
},
26+
address: {
27+
isString: true,
28+
},
2629
} as const;

src/driver.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
114114
'flutter: dragAndDrop': {
115115
command: 'dragAndDrop',
116116
params: {
117-
required: ['source', 'target']
118-
}
119-
}
117+
required: ['source', 'target'],
118+
},
119+
},
120120
};
121121

122122
async doubleClick(origin: any, offset: any) {
@@ -246,28 +246,39 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
246246
: this.proxydriver.opts.bundleId!;
247247

248248
const portcallbacks: {
249-
portForwardCallback?: PortForwardCallback,
250-
portReleaseCallback?: PortReleaseCallback,
249+
portForwardCallback?: PortForwardCallback;
250+
portReleaseCallback?: PortReleaseCallback;
251251
} = {};
252252
if (this.proxydriver instanceof AndroidUiautomator2Driver) {
253-
portcallbacks.portForwardCallback = async (_: string, systemPort: number, devicePort: number) => await androidPortForward(
254-
// @ts-ignore ADB instance is ok
255-
(this.proxydriver as AndroidUiautomator2Driver).adb,
256-
systemPort,
257-
devicePort
258-
);
259-
portcallbacks.portReleaseCallback = async (_: string, systemPort: number) => await androidRemovePortForward(
260-
// @ts-ignore ADB instance is ok
261-
(this.proxydriver as AndroidUiautomator2Driver).adb,
262-
systemPort
263-
);
253+
portcallbacks.portForwardCallback = async (
254+
_: string,
255+
systemPort: number,
256+
devicePort: number,
257+
) =>
258+
await androidPortForward(
259+
// @ts-ignore ADB instance is ok
260+
(this.proxydriver as AndroidUiautomator2Driver).adb,
261+
systemPort,
262+
devicePort,
263+
);
264+
portcallbacks.portReleaseCallback = async (
265+
_: string,
266+
systemPort: number,
267+
) =>
268+
await androidRemovePortForward(
269+
// @ts-ignore ADB instance is ok
270+
(this.proxydriver as AndroidUiautomator2Driver).adb,
271+
systemPort,
272+
);
264273
} else if (this.proxydriver.isRealDevice()) {
265274
portcallbacks.portForwardCallback = iosPortForward;
266275
portcallbacks.portReleaseCallback = iosRemovePortForward;
267276
}
268277
const flutterCaps: DriverCaps<FlutterDriverConstraints> = {
269-
flutterServerLaunchTimeout: this.internalCaps.flutterServerLaunchTimeout || 5000,
270-
flutterSystemPort: this.internalCaps.flutterSystemPort || await getFreePort(),
278+
flutterServerLaunchTimeout:
279+
this.internalCaps.flutterServerLaunchTimeout || 5000,
280+
flutterSystemPort:
281+
this.internalCaps.flutterSystemPort || (await getFreePort()),
271282
} as DriverCaps<FlutterDriverConstraints>;
272283
const systemPort =
273284
this.proxydriver instanceof XCUITestDriver &&
@@ -281,7 +292,7 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
281292
packageName,
282293
...portcallbacks,
283294
systemPort,
284-
flutterCaps
295+
flutterCaps,
285296
});
286297

287298
if (!this.flutterPort) {
@@ -294,7 +305,7 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
294305

295306
// @ts-ignore
296307
this.proxy = new JWProxy({
297-
server: '127.0.0.1',
308+
server: this.internalCaps.address || '127.0.0.1',
298309
port: this.flutterPort,
299310
});
300311

0 commit comments

Comments
 (0)