Skip to content

Commit 4cb9eb6

Browse files
Add support for flutter prefixed locator (#20)
* fix: find element to adhere visibilty * Fix finder * Support for backward compatibility * Version bump * Refactor find elements * Fix typo
1 parent de1c0e4 commit 4cb9eb6

File tree

8 files changed

+61
-181
lines changed

8 files changed

+61
-181
lines changed

demo-app/pubspec.lock

+25-129
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4-
_fe_analyzer_shared:
4+
a_bridge:
55
dependency: transitive
66
description:
7-
name: _fe_analyzer_shared
8-
sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
7+
name: a_bridge
8+
sha256: "5acd8dd8ba187576533aa93cd27c56695b9400ad282a89ce0b23f5b998fc78f3"
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "67.0.0"
12-
analyzer:
13-
dependency: transitive
14-
description:
15-
name: analyzer
16-
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
17-
url: "https://pub.dev"
18-
source: hosted
19-
version: "6.4.1"
11+
version: "0.0.3"
2012
appium_flutter_server:
2113
dependency: "direct dev"
2214
description:
2315
path: "../server"
2416
relative: true
2517
source: path
26-
version: "0.0.13"
27-
args:
28-
dependency: transitive
29-
description:
30-
name: args
31-
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
32-
url: "https://pub.dev"
33-
source: hosted
34-
version: "2.5.0"
18+
version: "0.0.18"
3519
async:
3620
dependency: transitive
3721
description:
@@ -48,22 +32,6 @@ packages:
4832
url: "https://pub.dev"
4933
source: hosted
5034
version: "2.1.1"
51-
build:
52-
dependency: transitive
53-
description:
54-
name: build
55-
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
56-
url: "https://pub.dev"
57-
source: hosted
58-
version: "2.4.1"
59-
build_config:
60-
dependency: transitive
61-
description:
62-
name: build_config
63-
sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1
64-
url: "https://pub.dev"
65-
source: hosted
66-
version: "1.1.1"
6735
carousel_slider:
6836
dependency: "direct main"
6937
description:
@@ -80,14 +48,6 @@ packages:
8048
url: "https://pub.dev"
8149
source: hosted
8250
version: "1.3.0"
83-
checked_yaml:
84-
dependency: transitive
85-
description:
86-
name: checked_yaml
87-
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
88-
url: "https://pub.dev"
89-
source: hosted
90-
version: "2.0.3"
9151
clock:
9252
dependency: transitive
9353
description:
@@ -128,14 +88,22 @@ packages:
12888
url: "https://pub.dev"
12989
source: hosted
13090
version: "1.0.8"
131-
dart_style:
91+
device_info_plus:
92+
dependency: transitive
93+
description:
94+
name: device_info_plus
95+
sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91
96+
url: "https://pub.dev"
97+
source: hosted
98+
version: "10.1.0"
99+
device_info_plus_platform_interface:
132100
dependency: transitive
133101
description:
134-
name: dart_style
135-
sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9"
102+
name: device_info_plus_platform_interface
103+
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
136104
url: "https://pub.dev"
137105
source: hosted
138-
version: "2.3.6"
106+
version: "7.0.0"
139107
fake_async:
140108
dependency: transitive
141109
description:
@@ -193,14 +161,6 @@ packages:
193161
description: flutter
194162
source: sdk
195163
version: "0.0.0"
196-
glob:
197-
dependency: transitive
198-
description:
199-
name: glob
200-
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
201-
url: "https://pub.dev"
202-
source: hosted
203-
version: "2.1.2"
204164
hotreloader:
205165
dependency: transitive
206166
description:
@@ -238,22 +198,6 @@ packages:
238198
description: flutter
239199
source: sdk
240200
version: "0.0.0"
241-
json_annotation:
242-
dependency: transitive
243-
description:
244-
name: json_annotation
245-
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
246-
url: "https://pub.dev"
247-
source: hosted
248-
version: "4.9.0"
249-
json_serializable:
250-
dependency: transitive
251-
description:
252-
name: json_serializable
253-
sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b
254-
url: "https://pub.dev"
255-
source: hosted
256-
version: "6.8.0"
257201
leak_tracker:
258202
dependency: transitive
259203
description:
@@ -334,14 +278,6 @@ packages:
334278
url: "https://pub.dev"
335279
source: hosted
336280
version: "1.0.0"
337-
package_config:
338-
dependency: transitive
339-
description:
340-
name: package_config
341-
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
342-
url: "https://pub.dev"
343-
source: hosted
344-
version: "2.1.0"
345281
package_info_plus:
346282
dependency: transitive
347283
description:
@@ -486,30 +422,6 @@ packages:
486422
url: "https://pub.dev"
487423
source: hosted
488424
version: "5.0.2"
489-
pub_semver:
490-
dependency: transitive
491-
description:
492-
name: pub_semver
493-
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
494-
url: "https://pub.dev"
495-
source: hosted
496-
version: "2.1.4"
497-
pubspec_parse:
498-
dependency: transitive
499-
description:
500-
name: pubspec_parse
501-
sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8
502-
url: "https://pub.dev"
503-
source: hosted
504-
version: "1.3.0"
505-
quiver:
506-
dependency: transitive
507-
description:
508-
name: quiver
509-
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
510-
url: "https://pub.dev"
511-
source: hosted
512-
version: "3.2.1"
513425
shelf:
514426
dependency: transitive
515427
description:
@@ -563,22 +475,6 @@ packages:
563475
description: flutter
564476
source: sdk
565477
version: "0.0.99"
566-
source_gen:
567-
dependency: transitive
568-
description:
569-
name: source_gen
570-
sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
571-
url: "https://pub.dev"
572-
source: hosted
573-
version: "1.5.0"
574-
source_helper:
575-
dependency: transitive
576-
description:
577-
name: source_helper
578-
sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd"
579-
url: "https://pub.dev"
580-
source: hosted
581-
version: "1.3.4"
582478
source_span:
583479
dependency: transitive
584480
description:
@@ -811,22 +707,22 @@ packages:
811707
url: "https://pub.dev"
812708
source: hosted
813709
version: "5.5.1"
814-
xdg_directories:
710+
win32_registry:
815711
dependency: transitive
816712
description:
817-
name: xdg_directories
818-
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
713+
name: win32_registry
714+
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
819715
url: "https://pub.dev"
820716
source: hosted
821-
version: "1.0.4"
822-
yaml:
717+
version: "1.1.3"
718+
xdg_directories:
823719
dependency: transitive
824720
description:
825-
name: yaml
826-
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
721+
name: xdg_directories
722+
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
827723
url: "https://pub.dev"
828724
source: hosted
829-
version: "3.1.2"
725+
version: "1.0.4"
830726
sdks:
831727
dart: ">=3.4.0 <4.0.0"
832728
flutter: ">=3.22.0"

playground/locator-strategies.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
{
12-
"strategy": "text containting",
12+
"strategy": "text containing",
1313
"selector": "Text on the element contains"
1414
}
1515

server/lib/src/appium_test_bindings.dart

+3
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ class AppiumTestWidgetsFlutterBinding
2323

2424
@override
2525
TestBindingEventSource get pointerEventSource => TestBindingEventSource.test;
26+
27+
@override
28+
bool get registerTestTextInput => true;
2629
}

server/lib/src/handler/find_elements.dart

+3-12
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,17 @@ class FindElementstHandler extends RequestHandler {
2020
FindElementModel model =
2121
FindElementModel.fromJson(await request.body.asJson);
2222

23-
final String method = model.strategy;
24-
final String selector = model.selector;
2523
final String? contextId = model.context == "" ? null : model.context;
2624

27-
if (contextId == null) {
28-
log('"method: $method, selector: $selector');
29-
} else {
30-
log('"method: $method, selector: $selector, contextId: $contextId');
31-
}
32-
3325
Session? session = FlutterDriver.instance.getSessionOrThrow();
34-
final Finder by = ElementLookupStrategy.values
35-
.firstWhere((val) => val.name == method)
36-
.toFinder(selector);
26+
final Finder by =
27+
await ElementHelper.locateElement(model, evaluatePresence: false);
3728
List<Finder> matchedByList = [];
3829
try {
3930
matchedByList =
4031
await ElementHelper.findElements(by, contextId: contextId);
4132
} on ElementNotFoundException catch (e) {
42-
log("Got an exception while looking for multiple matches using method: $method, selector: $selector");
33+
log("Got an exception while looking for multiple matches using method: ${model.strategy}, selector: ${model.selector}");
4334
log(e);
4435
return AppiumResponse(session!.sessionId, matchedByList);
4536
}

server/lib/src/internal/element_lookup_strategy.dart

+17-21
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ enum ElementLookupStrategy {
88
BY_TOOLTIP,
99
BY_TEXT,
1010
BY_TEXT_CONTAINING,
11+
BY_TYPE,
12+
BY_ICON_POINT,
13+
BY_ICON_NAME
1114
// BY_ICON,
1215
// BY_ELEMENT_PREDICATE,
1316
// BY_SUBTYPE,
14-
BY_TYPE,
1517
// BY_WIDGET,
1618
//BY_WIDGET_PREDICATE,
17-
18-
//Custom Selectors
19-
//BY_WIDGET_NAME,
20-
BY_ICON_POINT,
21-
BY_ICON_NAME
2219
}
2320

2421
var a = Icons.accessible;
@@ -65,34 +62,33 @@ extension ElementLookupStrategyExtension on ElementLookupStrategy {
6562
String get name {
6663
switch (this) {
6764
case ElementLookupStrategy.BY_KEY:
68-
return 'key';
65+
return '-flutter key';
6966
case ElementLookupStrategy.BY_SEMANTICS_LABEL:
70-
return 'semantics label';
67+
return '-flutter semantics label';
7168
case ElementLookupStrategy.BY_TOOLTIP:
72-
return 'tooltip';
69+
return '-flutter tooltip';
7370
case ElementLookupStrategy.BY_TEXT:
74-
return 'text';
71+
return '-flutter text';
7572
case ElementLookupStrategy.BY_TEXT_CONTAINING:
76-
return 'text containting';
77-
73+
return '-flutter text containing';
7874
case ElementLookupStrategy.BY_TYPE:
79-
return 'type';
75+
return '-flutter type';
8076
case ElementLookupStrategy.BY_ICON_POINT:
81-
return 'icon point';
77+
return '-flutter icon point';
8278
case ElementLookupStrategy.BY_ICON_NAME:
83-
return 'icon name';
79+
return '-flutter icon name';
8480
// case ElementLookupStrategy.BY_ICON:
85-
// return 'icon';
81+
// return '-flutter icon';
8682
// case ElementLookupStrategy.BY_ELEMENT_PREDICATE:
87-
// return 'element predicate';
83+
// return '-flutter element predicate';
8884
// case ElementLookupStrategy.BY_SUBTYPE:
89-
// return 'subtype';
85+
// return '-flutter subtype';
9086
// case ElementLookupStrategy.BY_TYPE:
91-
// return 'type';
87+
// return '-flutter type';
9288
// case ElementLookupStrategy.BY_WIDGET:
93-
// return 'widget';
89+
// return '-flutter widget';
9490
// case ElementLookupStrategy.BY_WIDGET_PREDICATE:
95-
// return 'widget predicate';
91+
// return '-flutter widget predicate';
9692
}
9793
}
9894
}

0 commit comments

Comments
 (0)