From 8038c52e3f2b0f98ed131294f54ab421ab2cef9f Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Fri, 3 Dec 2021 16:31:28 +0200 Subject: [PATCH 1/5] #1074 fix compose button tap --- FlowCryptUI/Nodes/ComposeButtonNode.swift | 1 + appium/tests/helpers/ElementHelper.ts | 8 +++++--- appium/tests/screenobjects/mail-folder.screen.ts | 9 ++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/FlowCryptUI/Nodes/ComposeButtonNode.swift b/FlowCryptUI/Nodes/ComposeButtonNode.swift index 3cdd29b95..912302802 100644 --- a/FlowCryptUI/Nodes/ComposeButtonNode.swift +++ b/FlowCryptUI/Nodes/ComposeButtonNode.swift @@ -15,6 +15,7 @@ public final class ComposeButtonNode: ASButtonNode { super.init() onTap = action backgroundColor = .main + accessibilityIdentifier = "composeMessageButton" setTitle("+", with: UIFont.boldSystemFont(ofSize: 30), with: .white, for: .normal) addTarget(self, action: #selector(onButtonTap), forControlEvents: .touchUpInside) } diff --git a/appium/tests/helpers/ElementHelper.ts b/appium/tests/helpers/ElementHelper.ts index 4d546c95b..8592ff44a 100644 --- a/appium/tests/helpers/ElementHelper.ts +++ b/appium/tests/helpers/ElementHelper.ts @@ -44,10 +44,12 @@ class ElementHelper { await element.doubleClick(); } - static waitAndClick = async (element: WebdriverIO.Element, delayMs = 50) => { - await element.waitForDisplayed(); + static waitAndClick = async (element: WebdriverIO.Element, delayMs?: number) => { + await this.waitElementVisible(element); // stability fix to make sure element is ready for interaction - await browser.pause(delayMs); + if (delayMs !== undefined) { + await browser.pause(delayMs); + } await element.click(); } diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index b5d8220a5..da8530be5 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -5,7 +5,7 @@ import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { TRASH_HEADER: '-ios class chain:**/XCUIElementTypeNavigationBar[`name == "TRASH"`]', SENT_HEADER: '-ios class chain:**/XCUIElementTypeNavigationBar[`name == "SENT"`]', - CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]', + CREATE_EMAIL_BUTTON: '~composeMessageButton', INBOX_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "INBOX"`]', SEARCH_ICON: '~search icn', HELP_ICON: '~help icn', @@ -74,12 +74,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.scrollDownToElement(await this.createEmailButton); - await (await this.createEmailButton).waitForDisplayed(); - } - await ElementHelper.waitAndClick(await this.createEmailButton, 1000); // delay needed on M1 + await ElementHelper.waitAndClick(await this.createEmailButton); } clickOnUserEmail = async (email: string) => { From 80cbe209cb9e7cdb2f84c82e95cad4fe16709d1d Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Wed, 8 Dec 2021 12:37:40 +0200 Subject: [PATCH 2/5] #1151 update package.json --- FlowCryptUI/Nodes/ComposeButtonNode.swift | 2 +- appium/config/wdio.shared.conf.js | 4 ++-- appium/package.json | 24 +++++++++++------------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/FlowCryptUI/Nodes/ComposeButtonNode.swift b/FlowCryptUI/Nodes/ComposeButtonNode.swift index 912302802..9f51def89 100644 --- a/FlowCryptUI/Nodes/ComposeButtonNode.swift +++ b/FlowCryptUI/Nodes/ComposeButtonNode.swift @@ -16,7 +16,7 @@ public final class ComposeButtonNode: ASButtonNode { onTap = action backgroundColor = .main accessibilityIdentifier = "composeMessageButton" - setTitle("+", with: UIFont.boldSystemFont(ofSize: 30), with: .white, for: .normal) + setTitle("+", with: .boldSystemFont(ofSize: 30), with: .white, for: .normal) addTarget(self, action: #selector(onButtonTap), forControlEvents: .touchUpInside) } diff --git a/appium/config/wdio.shared.conf.js b/appium/config/wdio.shared.conf.js index f12b8a0d5..e47be4a1d 100644 --- a/appium/config/wdio.shared.conf.js +++ b/appium/config/wdio.shared.conf.js @@ -11,9 +11,9 @@ exports.config = { runner: 'local', framework: 'jasmine', - jasmineNodeOpts: { + jasmineOpts: { defaultTimeoutInterval: 600000, - requires: ['ts-node/register', 'tsconfig-paths/register'] + requires: ['tsconfig-paths/register'] }, sync: true, logLevel: 'silent', diff --git a/appium/package.json b/appium/package.json index f0b612fb2..b8d456c78 100644 --- a/appium/package.json +++ b/appium/package.json @@ -5,9 +5,9 @@ "main": "index.js", "scripts": { "test.live.all": "./node_modules/.bin/wdio ./config/wdio.live.conf.js --suite all", - "test.live": "./node_modules/.bin/wdio ./config/wdio.live.conf.js --suite all --jasmineNodeOpts.grep", + "test.live": "./node_modules/.bin/wdio ./config/wdio.live.conf.js --suite all --jasmineOpts.grep", "test.mock.all": "./node_modules/.bin/wdio ./config/wdio.mock.conf.js --suite all", - "test.mock": "./node_modules/.bin/wdio ./config/wdio.mock.conf.js --suite all --jasmineNodeOpts.grep", + "test.mock": "./node_modules/.bin/wdio ./config/wdio.mock.conf.js --suite all --jasmineOpts.grep", "test": "npm run-script build.app && npm run-script only.test.all", "lint": "cd .. && ./appium/node_modules/.bin/eslint appium/ --ext .ts" }, @@ -25,20 +25,18 @@ "@types/request": "^2.48.7", "@typescript-eslint/eslint-plugin": "^5.3.1", "@typescript-eslint/parser": "^5.3.1", - "@wdio/allure-reporter": "7.16.3", - "@wdio/appium-service": "7.16.4", - "@wdio/cli": "7.16.4", - "@wdio/jasmine-framework": "7.16.4", - "@wdio/local-runner": "6.10.13", - "@wdio/spec-reporter": "6.10.6", - "appium": "1.22.0", + "@wdio/allure-reporter": "7.16.10", + "@wdio/appium-service": "7.16.6", + "@wdio/cli": "7.16.10", + "@wdio/jasmine-framework": "7.16.6", + "@wdio/local-runner": "7.16.10", + "@wdio/spec-reporter": "7.16.9", + "appium": "1.22.1", "babel-eslint": "^10.1.0", "dotenv": "^10.0.0", - "eslint": "^8.2.0", - "eslint-config-standard": "^16.0.3", + "eslint": "^8.4.1", "eslint-plugin-import": "^2.25.2", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.1", "eslint-plugin-wdio": "^7.4.2", "mailparser": "3.4.0", "node-fetch": "^3.1.0", @@ -49,6 +47,6 @@ "ts-node": "^10.4.0", "typescript": "^4.4.4", "wdio-video-reporter": "^3.1.3", - "webdriverio": "7.16.4" + "webdriverio": "7.16.10" } } \ No newline at end of file From a64ece18d80427763eeab9c2bf514fb7669b05c7 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Mon, 13 Dec 2021 16:49:27 +0200 Subject: [PATCH 3/5] #1074 use scrollDownToElement --- appium/config/wdio.live.conf.js | 1 + appium/package.json | 2 +- appium/tests/screenobjects/mail-folder.screen.ts | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/appium/config/wdio.live.conf.js b/appium/config/wdio.live.conf.js index de9c1568d..23bb32a9e 100644 --- a/appium/config/wdio.live.conf.js +++ b/appium/config/wdio.live.conf.js @@ -29,6 +29,7 @@ config.capabilities = [ platformVersion: '15.0', automationName: 'XCUITest', app: join(process.cwd(), './FlowCrypt.app'), + simpleIsVisibleCheck: true, newCommandTimeout: 10000, wdaLaunchTimeout: 300000, wdaConnectionTimeout: 600000, diff --git a/appium/package.json b/appium/package.json index 387826bb0..557e560f0 100644 --- a/appium/package.json +++ b/appium/package.json @@ -31,7 +31,7 @@ "@wdio/jasmine-framework": "^7.16.6", "@wdio/local-runner": "^7.16.10", "@wdio/spec-reporter": "^7.16.9", - "appium": "1.22.1", + "appium": "^1.22.1", "babel-eslint": "^10.1.0", "dotenv": "^10.0.0", "eslint": "^8.4.1", diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index c7b162214..57ca3d3ae 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -74,7 +74,9 @@ class MailFolderScreen extends BaseScreen { } clickCreateEmail = async () => { - await ElementHelper.waitAndClick(await this.createEmailButton); + const elem = await this.createEmailButton; + await TouchHelper.scrollDownToElement(elem); + await elem.click(); } clickOnUserEmail = async (email: string) => { From 93e451ebf08d574dfe75ac337859a7fed05f1aef Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Mon, 13 Dec 2021 21:45:58 +0200 Subject: [PATCH 4/5] #1074 update clickCreateEmail --- appium/tests/helpers/TouchHelper.ts | 2 +- appium/tests/screenobjects/mail-folder.screen.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/appium/tests/helpers/TouchHelper.ts b/appium/tests/helpers/TouchHelper.ts index 33ab74a58..f74522070 100644 --- a/appium/tests/helpers/TouchHelper.ts +++ b/appium/tests/helpers/TouchHelper.ts @@ -40,7 +40,7 @@ class TouchHelper { // this wait can be later replaced by waiting for loader to go away before scrolling await browser.pause(1000); // make sure contents are loaded first, so we don't scroll too early for(let i = 0; i < 15; i++) { - if (await (await element).isDisplayed()) { + if (await element.isDisplayed()) { return; } await driver.touchPerform([ diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index 57ca3d3ae..e4c86b10f 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -75,8 +75,11 @@ class MailFolderScreen extends BaseScreen { clickCreateEmail = async () => { const elem = await this.createEmailButton; - await TouchHelper.scrollDownToElement(elem); - await elem.click(); + if ((await elem.isDisplayed()) !== true) { + await TouchHelper.scrollDownToElement(elem); + await elem.waitForDisplayed(); + } + await ElementHelper.waitAndClick(elem); } clickOnUserEmail = async (email: string) => { From cf678d7512ad801b066377b447e30dd1053d0ac4 Mon Sep 17 00:00:00 2001 From: Roma Sosnovsky Date: Mon, 13 Dec 2021 22:31:28 +0200 Subject: [PATCH 5/5] #1074 PR updates --- FlowCryptUI/Nodes/ComposeButtonNode.swift | 2 +- appium/package.json | 2 +- appium/tests/helpers/ElementHelper.ts | 6 ++---- appium/tests/screenobjects/mail-folder.screen.ts | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/FlowCryptUI/Nodes/ComposeButtonNode.swift b/FlowCryptUI/Nodes/ComposeButtonNode.swift index 9f51def89..2367342ec 100644 --- a/FlowCryptUI/Nodes/ComposeButtonNode.swift +++ b/FlowCryptUI/Nodes/ComposeButtonNode.swift @@ -15,7 +15,7 @@ public final class ComposeButtonNode: ASButtonNode { super.init() onTap = action backgroundColor = .main - accessibilityIdentifier = "composeMessageButton" + accessibilityIdentifier = "aid-compose-message-button" setTitle("+", with: .boldSystemFont(ofSize: 30), with: .white, for: .normal) addTarget(self, action: #selector(onButtonTap), forControlEvents: .touchUpInside) } diff --git a/appium/package.json b/appium/package.json index 557e560f0..387826bb0 100644 --- a/appium/package.json +++ b/appium/package.json @@ -31,7 +31,7 @@ "@wdio/jasmine-framework": "^7.16.6", "@wdio/local-runner": "^7.16.10", "@wdio/spec-reporter": "^7.16.9", - "appium": "^1.22.1", + "appium": "1.22.1", "babel-eslint": "^10.1.0", "dotenv": "^10.0.0", "eslint": "^8.4.1", diff --git a/appium/tests/helpers/ElementHelper.ts b/appium/tests/helpers/ElementHelper.ts index 2c89b25dd..9f8350ff2 100644 --- a/appium/tests/helpers/ElementHelper.ts +++ b/appium/tests/helpers/ElementHelper.ts @@ -49,12 +49,10 @@ class ElementHelper { await element.doubleClick(); } - static waitAndClick = async (element: WebdriverIO.Element, delayMs?: number) => { + static waitAndClick = async (element: WebdriverIO.Element, delayMs = 50) => { await this.waitElementVisible(element); // stability fix to make sure element is ready for interaction - if (delayMs !== undefined) { - await browser.pause(delayMs); - } + await browser.pause(delayMs); await element.click(); } diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index e4c86b10f..0b55d448a 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -5,7 +5,7 @@ import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { TRASH_HEADER: '~navigationItemTrash', SENT_HEADER: '~navigationItemSent', - CREATE_EMAIL_BUTTON: '~composeMessageButton', + CREATE_EMAIL_BUTTON: '~aid-compose-message-button', INBOX_HEADER: '~navigationItemInbox', SEARCH_ICON: '~search icn', HELP_ICON: '~help icn',