@@ -13,6 +13,30 @@ async function performLogin(userName = 'admin', password = '1234') {
1313 await browser . flutterByValueKey$ ( 'LoginButton' ) . click ( ) ;
1414}
1515
16+ async function handleAppManagement ( ) {
17+ const currentContext = await browser . getContext ( ) ;
18+ if ( currentContext !== 'NATIVE_APP' ) {
19+ await browser . switchContext ( 'NATIVE_APP' ) ;
20+ }
21+
22+ const appID = browser . isIOS
23+ ? 'com.example.appiumTestingApp'
24+ : 'com.example.appium_testing_app' ;
25+ if ( await browser . isAppInstalled ( appID ) ) {
26+ await browser . removeApp ( appID ) ;
27+ }
28+ await browser . installApp ( process . env . APP_PATH ) ;
29+ await browser . pause ( 2000 ) ;
30+ if ( await browser . isAppInstalled ( appID ) ) {
31+ console . log ( 'App is installed' ) ;
32+ await browser . execute ( 'flutter: launchApp' , {
33+ appId : appID ,
34+ arguments : [ '--dummy-arguments' ] ,
35+ environment : { } ,
36+ } ) ;
37+ }
38+ }
39+
1640function itForAndroidOnly ( description , fn ) {
1741 if ( browser . isIOS ) {
1842 it . skip ( description , fn ) ;
@@ -46,27 +70,7 @@ async function switchToWebview(timeout = 20000) {
4670
4771describe ( 'My Login application' , ( ) => {
4872 afterEach ( async ( ) => {
49- const currentContext = await browser . getContext ( ) ;
50- if ( currentContext !== 'NATIVE_APP' ) {
51- await browser . switchContext ( 'NATIVE_APP' ) ;
52- }
53-
54- const appID = browser . isIOS
55- ? 'com.example.appiumTestingApp'
56- : 'com.example.appium_testing_app' ;
57- if ( await browser . isAppInstalled ( appID ) ) {
58- await browser . removeApp ( appID ) ;
59- }
60- await browser . installApp ( process . env . APP_PATH ) ;
61- await browser . pause ( 2000 ) ;
62- if ( await browser . isAppInstalled ( appID ) ) {
63- console . log ( 'App is installed' ) ;
64- await browser . execute ( 'flutter: launchApp' , {
65- appId : appID ,
66- arguments : [ '--dummy-arguments' ] ,
67- environment : { } ,
68- } ) ;
69- }
73+ await handleAppManagement ( ) ;
7074 } ) ;
7175
7276 it ( 'Create Session with Flutter Integration Driver' , async ( ) => {
0 commit comments