From 017ea81e00e1e29e51d879e302856a35f534022e Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Mon, 13 Dec 2021 17:18:49 +0200 Subject: [PATCH] added fixes for check attachment --- .../tests/screenobjects/attachment.screen.ts | 29 +++++++++++++++++-- appium/tests/screenobjects/email.screen.ts | 2 +- .../live/inbox/ReadAttachmentEmail.spec.ts | 19 ++++++++---- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/appium/tests/screenobjects/attachment.screen.ts b/appium/tests/screenobjects/attachment.screen.ts index f23360c03..a324f957d 100644 --- a/appium/tests/screenobjects/attachment.screen.ts +++ b/appium/tests/screenobjects/attachment.screen.ts @@ -2,7 +2,9 @@ import BaseScreen from './base.screen'; import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { - BACK_BTN: '~arrow left c' + BACK_BTN: '~arrow left c', + SAVE_BTN: '-ios class chain:**/XCUIElementTypeButton[`label == "Save"`]', + CANCEL_BTN: '~Cancel', }; class AttachmentScreen extends BaseScreen { @@ -14,8 +16,16 @@ class AttachmentScreen extends BaseScreen { return $(SELECTORS.BACK_BTN); } + get saveButton() { + return $(SELECTORS.SAVE_BTN); + } + + get cancelButton() { + return $(SELECTORS.CANCEL_BTN) + } + checkDownloadPopUp = async (name: string) => { - await (await this.backButton).waitForDisplayed(); + await (await this.cancelButton).waitForDisplayed(); const attachment = `-ios class chain:**/XCUIElementTypeNavigationBar[\`name == "com_apple_DocumentManager_Service.DOCServiceTargetSelectionBrowserView"\`]/XCUIElementTypeButton/XCUIElementTypeStaticText`;//it works only with this selector expect(await $(attachment)).toHaveAttribute('value', `${name}`); } @@ -23,6 +33,21 @@ class AttachmentScreen extends BaseScreen { clickBackButton = async () => { await ElementHelper.waitAndClick(await this.backButton); } + + clickCancelButton = async () => { + await ElementHelper.waitAndClick(await this.cancelButton); + } + + checkAttachment = async (name: string) => { + await (await this.backButton).waitForDisplayed(); + const attachmentHeader = `-ios class chain:**/XCUIElementTypeNavigationBar[\`name == "${name}"\`]`; + expect(await $(attachmentHeader)).toBeDisplayed(); + await (await this.saveButton).waitForDisplayed(); + } + + clickSaveButton = async () => { + await ElementHelper.waitAndClick(await this.saveButton); + } } export default new AttachmentScreen(); diff --git a/appium/tests/screenobjects/email.screen.ts b/appium/tests/screenobjects/email.screen.ts index ce53bca5e..032b0bc8b 100644 --- a/appium/tests/screenobjects/email.screen.ts +++ b/appium/tests/screenobjects/email.screen.ts @@ -8,7 +8,7 @@ const SELECTORS = { OK_BUTTON: '~Ok', WRONG_PASS_PHRASE_MESSAGE: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Wrong pass phrase, please try again"`]', ATTACHMENT_CELL: '~attachmentCell0', - ATTACHMENT_TITLE: 'attachmentTitleLabel0', + ATTACHMENT_TITLE: '~attachmentTitleLabel0', REPLY_BUTTON: '~replyButton', RECIPIENTS_BUTTON: '~messageRecipientButton', RECIPIENTS_TO_LABEL: '~toLabel0', diff --git a/appium/tests/specs/live/inbox/ReadAttachmentEmail.spec.ts b/appium/tests/specs/live/inbox/ReadAttachmentEmail.spec.ts index 473b41d72..35823200d 100644 --- a/appium/tests/specs/live/inbox/ReadAttachmentEmail.spec.ts +++ b/appium/tests/specs/live/inbox/ReadAttachmentEmail.spec.ts @@ -28,7 +28,7 @@ describe('INBOX: ', () => { await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); - // FIXME await EmailScreen.checkAttachment(attachmentName); + await EmailScreen.checkAttachment(attachmentName); await driver.terminateApp(bundleId); await driver.activateApp(bundleId); @@ -46,21 +46,28 @@ describe('INBOX: ', () => { await EmailScreen.enterPassPhrase(correctPassPhrase); await EmailScreen.clickOkButton(); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); - // FIXME await EmailScreen.checkAttachment(attachmentName); + await EmailScreen.checkAttachment(attachmentName); await EmailScreen.clickOnAttachmentCell(); + await AttachmentScreen.checkAttachment(attachmentName); - // FIXME await AttachmentScreen.checkDownloadPopUp(attachmentName); - await browser.pause(2000); // TODO + await AttachmentScreen.clickSaveButton(); + + await AttachmentScreen.checkDownloadPopUp(attachmentName); + await AttachmentScreen.clickCancelButton(); + await AttachmentScreen.checkAttachment(attachmentName); await AttachmentScreen.clickBackButton(); - // FIXME await EmailScreen.checkAttachment(attachmentName); + await EmailScreen.checkAttachment(attachmentName); await EmailScreen.clickBackButton(); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); - // FIXME await EmailScreen.checkAttachment(attachmentName); + await EmailScreen.checkAttachment(attachmentName); await EmailScreen.clickOnAttachmentCell(); + await AttachmentScreen.checkAttachment(attachmentName); + + await AttachmentScreen.clickSaveButton(); await AttachmentScreen.checkDownloadPopUp(attachmentName); }); });