2
2
// import * as assert from 'assert';
3
3
const wdio = require ( 'webdriverio' ) ;
4
4
const assert = require ( 'assert' ) ;
5
- const { byValueKey } = require ( 'appium-flutter-finder' ) ;
6
-
7
- const osSpecificOps = process . env . APPIUM_OS === 'android' ? {
8
- platformName : 'Android' ,
9
- deviceName : 'Pixel 2' ,
10
- // @todo support non-unix style path
11
- app : __dirname + '/../apps/app-free-debug.apk' ,
12
- } : process . env . APPIUM_OS === 'ios' ? {
13
- platformName : 'iOS' ,
14
- platformVersion : '12.2' ,
15
- deviceName : 'iPhone X' ,
16
- noReset : true ,
17
- app : __dirname + '/../apps/Runner.zip' ,
18
-
19
- } : { } ;
5
+ const find = require ( 'appium-flutter-finder' ) ;
6
+
7
+ const osSpecificOps =
8
+ process . env . APPIUM_OS === 'android'
9
+ ? {
10
+ platformName : 'Android' ,
11
+ deviceName : 'Pixel 2' ,
12
+ // @todo support non-unix style path
13
+ app : __dirname + '/../apps/app-free-debug.apk'
14
+ }
15
+ : process . env . APPIUM_OS === 'ios'
16
+ ? {
17
+ platformName : 'iOS' ,
18
+ platformVersion : '12.2' ,
19
+ deviceName : 'iPhone X' ,
20
+ noReset : true ,
21
+ app : __dirname + '/../apps/Runner.zip'
22
+ }
23
+ : { } ;
20
24
21
25
const opts = {
22
26
port : 4723 ,
@@ -27,19 +31,22 @@ const opts = {
27
31
} ;
28
32
29
33
( async ( ) => {
30
- const counterTextFinder = byValueKey ( 'counter' ) ;
31
- const buttonFinder = byValueKey ( 'increment' ) ;
34
+ const counterTextFinder = find . byValueKey ( 'counter' ) ;
35
+ const buttonFinder = find . byValueKey ( 'increment' ) ;
32
36
33
37
const driver = await wdio . remote ( opts ) ;
34
38
39
+ /* new example
35
40
if (process.env.APPIUM_OS === 'android') {
36
41
await driver.switchContext('NATIVE_APP');
37
42
await (await driver.$('~fab')).click();
38
43
await driver.switchContext('FLUTTER');
39
44
} else {
40
- console . log ( 'Switching context to `NATIVE_APP` is currently only applicable to Android demo app.' )
45
+ console.log(
46
+ 'Switching context to `NATIVE_APP` is currently only applicable to Android demo app.'
47
+ );
41
48
}
42
-
49
+ */
43
50
44
51
assert . strictEqual ( await driver . getElementText ( counterTextFinder ) , '0' ) ;
45
52
@@ -49,8 +56,42 @@ const opts = {
49
56
element : { elementId : buttonFinder }
50
57
} ) ;
51
58
52
-
53
59
assert . strictEqual ( await driver . getElementText ( counterTextFinder ) , '2' ) ;
54
60
61
+ await driver . elementClick ( find . byTooltip ( 'Increment' ) ) ;
62
+
63
+ assert . strictEqual (
64
+ await driver . getElementText (
65
+ find . descendant ( {
66
+ of : find . byTooltip ( 'counter_tooltip' ) ,
67
+ matching : find . byValueKey ( 'counter' )
68
+ } )
69
+ ) ,
70
+ '3'
71
+ ) ;
72
+
73
+ await driver . elementClick ( find . byType ( 'FlatButton' ) ) ;
74
+ // await driver.waitForAbsent(byTooltip('counter_tooltip'));
75
+
76
+ assert . strictEqual (
77
+ await driver . getElementText ( find . byText ( 'This is 2nd route' ) ) ,
78
+ 'This is 2nd route'
79
+ ) ;
80
+
81
+ await driver . elementClick ( find . pageBack ( ) ) ;
82
+
83
+ assert . strictEqual (
84
+ await driver . getElementText (
85
+ find . descendant ( {
86
+ of : find . ancestor ( {
87
+ of : find . bySemanticsLabel ( RegExp ( 'counter_semantic' ) ) ,
88
+ matching : find . byType ( 'Tooltip' )
89
+ } ) ,
90
+ matching : find . byType ( 'Text' )
91
+ } )
92
+ ) ,
93
+ '3'
94
+ ) ;
95
+
55
96
driver . deleteSession ( ) ;
56
97
} ) ( ) ;
0 commit comments