Skip to content

Commit 26cf1d6

Browse files
Run web test for android only
Co-authored-by: SrinivasanTarget <srinivasan.sekar1990@gmail.com>
1 parent 2f672b0 commit 26cf1d6

4 files changed

Lines changed: 41 additions & 5 deletions

File tree

android.conf.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const config: WebdriverIO.Config = {
1313
'appium:app': process.env.APP_PATH,
1414
'appium:newCommandTimeout': 240,
1515
'appium:flutterServerLaunchTimeout': 10000,
16-
'appium:flutterEnableMockCamera': true
16+
'appium:flutterEnableMockCamera': true,
17+
'appium:adbExecTimeout': 80000
1718
},
1819
],
1920
};

test/SecondImage.png

130 KB
Loading

test/qr.png

32 KB
Loading

test/specs/test.e2e.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { browser, expect } from '@wdio/globals';
2+
import path from "path";
23

34
async function performLogin(userName = 'admin', password = '1234') {
45
await browser.takeScreenshot();
@@ -12,6 +13,14 @@ async function performLogin(userName = 'admin', password = '1234') {
1213
await browser.flutterByValueKey$('LoginButton').click();
1314
}
1415

16+
function itForAndroidOnly(description, fn) {
17+
if (browser.isIOS) {
18+
it.skip(description, fn);
19+
} else {
20+
it(description, fn);
21+
}
22+
}
23+
1524
async function openScreen(screenTitle) {
1625
const screenListElement = await browser.flutterScrollTillVisible({
1726
finder: await browser.flutterByText(screenTitle),
@@ -279,8 +288,9 @@ describe('My Login application', () => {
279288
.getText();
280289
expect(dropped).toEqual('The box is dropped');
281290
});
282-
283-
it('should switch to webview context and validate the page title', async () => {
291+
292+
//TODO: Wbview is not inspectable on iOS demo app, need to fix it.
293+
itForAndroidOnly('should switch to webview context and validate the page title', async () => {
284294
await performLogin();
285295
await openScreen('Web View');
286296
await switchToWebview();
@@ -300,7 +310,7 @@ describe('My Login application', () => {
300310
);
301311
});
302312

303-
it('should execute native commands correctly while in Webview context', async () => {
313+
itForAndroidOnly('should execute native commands correctly while in Webview context', async () => {
304314
await performLogin();
305315
await openScreen('Web View');
306316
await switchToWebview();
@@ -320,7 +330,7 @@ describe('My Login application', () => {
320330
expect(typeof pageSource).toBe('string');
321331
});
322332

323-
it('should switch back and forth between native and Webview contexts', async () => {
333+
itForAndroidOnly('should switch back and forth between native and Webview contexts', async () => {
324334
await performLogin();
325335
await openScreen('Web View');
326336

@@ -334,3 +344,28 @@ describe('My Login application', () => {
334344
expect(await browser.getContext()).toContain('WEBVIEW');
335345
});
336346
});
347+
348+
describe('Image mocking', async() => {
349+
afterEach(async () => {
350+
await handleAppManagement();
351+
});
352+
353+
it('Inject Image', async() => {
354+
const firstImageToMock = path.resolve('test/qr.png');
355+
const secondImageToMock = path.resolve('test/SecondImage.png');
356+
await performLogin();
357+
await openScreen('Image Picker');
358+
const firstInjectedImage = await browser.flutterInjectImage(firstImageToMock);
359+
await browser.flutterByValueKey$('capture_image').click();
360+
await browser.flutterByText$('PICK').click();
361+
expect(await browser.flutterByText$('Success!').isDisplayed()).toBe(true);
362+
await browser.flutterInjectImage(secondImageToMock);
363+
await browser.flutterByValueKey$('capture_image').click();
364+
await browser.flutterByText$('PICK').click();
365+
expect(await browser.flutterByText$('SecondInjectedImage').isDisplayed()).toBe(true);
366+
await browser.flutterActivateInjectedImage({ imageId: firstInjectedImage });
367+
await browser.flutterByValueKey$('capture_image').click();
368+
await browser.flutterByText$('PICK').click();
369+
expect(await browser.flutterByText$('Success!').isDisplayed()).toBe(true);
370+
})
371+
})

0 commit comments

Comments
 (0)