Skip to content

Commit c78bc29

Browse files
Handle appmgt
Co-authored-by: SrinivasanTarget <srinivasan.sekar1990@gmail.com>
1 parent 6daa6c7 commit c78bc29

1 file changed

Lines changed: 25 additions & 21 deletions

File tree

test/specs/test.e2e.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1640
function itForAndroidOnly(description, fn) {
1741
if (browser.isIOS) {
1842
it.skip(description, fn);
@@ -46,27 +70,7 @@ async function switchToWebview(timeout = 20000) {
4670

4771
describe('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

Comments
 (0)