diff --git a/appium/tests/helpers/ElementHelper.ts b/appium/tests/helpers/ElementHelper.ts index 1c53ad0ac..d0d7fc788 100644 --- a/appium/tests/helpers/ElementHelper.ts +++ b/appium/tests/helpers/ElementHelper.ts @@ -6,7 +6,7 @@ class ElementHelper { * returns true or false for element visibility */ static elementDisplayed = async (element: WebdriverIO.Element): Promise => { - return await element.isExisting(); + return await element.isDisplayed(); } static waitElementVisible = async (element: WebdriverIO.Element, timeout: number = DEFAULT_TIMEOUT) => { diff --git a/appium/tests/helpers/TouchHelper.ts b/appium/tests/helpers/TouchHelper.ts index 3c8cec067..a52725f4d 100644 --- a/appium/tests/helpers/TouchHelper.ts +++ b/appium/tests/helpers/TouchHelper.ts @@ -1,4 +1,5 @@ + class TouchHelper { /** @@ -29,6 +30,27 @@ class TouchHelper { {action: 'release', options: {}}, ]); } + + static scrollDownToElement = async (element: WebdriverIO.Element) => { + const { width, height } = await driver.getWindowSize(); + const anchor = width / 2; + const startPoint = height * 0.25; + const endPoint = height * 0.15; + let index = 0; + + do { + await browser.pause(1000); // due to scroll action which takes about second + await driver.touchPerform([ + {action: 'press', options: {x: anchor, y: startPoint}}, + {action: 'wait', options: {ms: 100}}, + {action: 'moveTo', options: {x: anchor, y: endPoint}}, + {action: 'release', options: {}}, + ]); + } while (await (await element).isDisplayed() !== true && index++ < 14); + + if(index === 15) throw new Error(`Element ${JSON.stringify(element.selector)} doesn't displayed after scroll`); + } + } export default TouchHelper; diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index 4df7ae415..2fb464f8e 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -61,9 +61,10 @@ class MailFolderScreen extends BaseScreen { } clickOnEmailBySubject = async (subject: string) => { + await expect(await this.helpIcon).toBeDisplayed(); const selector = `~${subject}`; if (await (await $(selector)).isDisplayed() !== true) { - await TouchHelper.scrollDown(); + await TouchHelper.scrollDownToElement(await $(selector)); } await ElementHelper.waitAndClick(await $(selector), 500); } @@ -71,7 +72,7 @@ class MailFolderScreen extends BaseScreen { clickCreateEmail = async () => { await browser.pause(2000); // todo: loading inbox. Fix this: wait until loader gone if (await (await this.createEmailButton).isDisplayed() !== true) { - await TouchHelper.scrollDown(); + await TouchHelper.scrollDownToElement(await this.createEmailButton); await (await this.createEmailButton).waitForDisplayed(); } await ElementHelper.waitAndClick(await this.createEmailButton, 1000); // delay needed on M1 @@ -83,11 +84,9 @@ class MailFolderScreen extends BaseScreen { } checkInboxScreen = async () => { - await (await this.inboxHeader).waitForDisplayed(); - if (await (await this.createEmailButton).isDisplayed() !== true) { - await TouchHelper.scrollDown(); - await (await this.createEmailButton).waitForDisplayed(); - } + await expect(await this.inboxHeader).toBeDisplayed(); + await expect(await this.searchIcon).toBeDisplayed(); + await expect(await this.helpIcon).toBeDisplayed() } } diff --git a/appium/tests/specs/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts index c63209478..ad1dcff7a 100644 --- a/appium/tests/specs/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts +++ b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts @@ -31,6 +31,7 @@ describe('COMPOSE EMAIL: ', () => { await driver.terminateApp(bundleId); await driver.activateApp(bundleId); + await MailFolderScreen.checkInboxScreen(); await MailFolderScreen.clickCreateEmail(); await NewMessageScreen.composeEmail(contactEmail, emailSubject, emailText); await NewMessageScreen.checkFilledComposeEmailInfo(contactEmail, emailSubject, emailText); diff --git a/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts b/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts index c717ff871..bcb9e9ee2 100644 --- a/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts +++ b/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts @@ -30,6 +30,7 @@ describe('INBOX: ', () => { await driver.terminateApp(bundleId); await driver.activateApp(bundleId); + await MailFolderScreen.checkInboxScreen(); await MailFolderScreen.clickOnEmailBySubject(emailSubject); //try to see encrypted message with wrong pass phrase diff --git a/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts b/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts index d7b3f82fa..544914b5a 100644 --- a/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts +++ b/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts @@ -32,6 +32,7 @@ describe('INBOX: ', () => { await driver.terminateApp(bundleId); await driver.activateApp(bundleId); + await MailFolderScreen.checkInboxScreen(); await MailFolderScreen.clickOnEmailBySubject(emailSubject); //try to see encrypted message with wrong pass phrase diff --git a/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts b/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts index 3a0f48207..a60266264 100644 --- a/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts +++ b/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts @@ -25,6 +25,7 @@ describe('INBOX: ', () => { await driver.terminateApp(CommonData.bundleId.id); await driver.activateApp(CommonData.bundleId.id); + await MailFolderScreen.checkInboxScreen(); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); }); diff --git a/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts b/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts index 9f70beb14..5acab837b 100644 --- a/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts +++ b/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts @@ -17,7 +17,7 @@ describe('INBOX: ', () => { await SplashScreen.login(); await SetupKeyScreen.setPassPhrase(); - await MailFolderScreen.checkInboxScreen() + await MailFolderScreen.checkInboxScreen(); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText);