22// import * as assert from 'assert';
33const wdio = require ( 'webdriverio' ) ;
44const 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+ : { } ;
2024
2125const opts = {
2226 port : 4723 ,
@@ -27,19 +31,22 @@ const opts = {
2731} ;
2832
2933( async ( ) => {
30- const counterTextFinder = byValueKey ( 'counter' ) ;
31- const buttonFinder = byValueKey ( 'increment' ) ;
34+ const counterTextFinder = find . byValueKey ( 'counter' ) ;
35+ const buttonFinder = find . byValueKey ( 'increment' ) ;
3236
3337 const driver = await wdio . remote ( opts ) ;
3438
39+ /* new example
3540 if (process.env.APPIUM_OS === 'android') {
3641 await driver.switchContext('NATIVE_APP');
3742 await (await driver.$('~fab')).click();
3843 await driver.switchContext('FLUTTER');
3944 } 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+ );
4148 }
42-
49+ */
4350
4451 assert . strictEqual ( await driver . getElementText ( counterTextFinder ) , '0' ) ;
4552
@@ -49,8 +56,42 @@ const opts = {
4956 element : { elementId : buttonFinder }
5057 } ) ;
5158
52-
5359 assert . strictEqual ( await driver . getElementText ( counterTextFinder ) , '2' ) ;
5460
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+
5596 driver . deleteSession ( ) ;
5697} ) ( ) ;
0 commit comments