From 7f439848484d0226e50ec81dab8af8dbf0aace16 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Tue, 23 Jan 2024 19:08:37 +0200 Subject: [PATCH 01/19] updated performSwipe with w3c protocol --- lib/helper/Appium.js | 54 ++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 2eae24a3d..93d8b4b40 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -1071,7 +1071,7 @@ class Appium extends Webdriver { onlyForApps.call(this); const res = await this.browser.$(parseLocator.call(this, locator)); // if (!res.length) throw new ElementNotFound(locator, 'was not found in UI'); - return this.performSwipe(await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); + return this.performSwipe(await res.elementId, await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); } /* eslint-enable */ @@ -1079,26 +1079,50 @@ class Appium extends Webdriver { * Perform a swipe on the screen. * * ```js - * I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 }); + * I.performSwipe(elementId, { x: 300, y: 100 }, { x: 200, y: 100 }); * ``` * + * @param {string} elementId * @param {object} from * @param {object} to * * Appium: support Android and iOS */ - async performSwipe(from, to) { - await this.browser.touchPerform([{ - action: 'press', - options: from, - }, { - action: 'wait', - options: { ms: 1000 }, - }, { - action: 'moveTo', - options: to, - }, { - action: 'release', + async performSwipe(elementId, from, to) { + await this.browser.performActions([{ + id: elementId, + type: 'pointer', + parameters: { + pointerType: 'touch', + }, + actions: [ + { + duration: 0, + x: from.x, + y: from.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerDown', + }, + { + duration: 600, + type: 'pause', + }, + { + duration: 600, + x: to.x, + y: to.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerUp', + }, + ], }]); await this.browser.pause(1000); } @@ -1128,7 +1152,7 @@ class Appium extends Webdriver { yoffset = 100; } - return this.swipe(locator, 0, yoffset, speed); + return this.swipe(parseLocator.call(this, locator), 0, yoffset, speed); } /** From a445b717a6e97cf1850af398f5c6575830c6f29b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 05:53:25 +0100 Subject: [PATCH 02/19] chore(deps-dev): bump @wdio/utils from 8.27.2 to 8.28.8 (#4152) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cd2806746..9921ad3bb 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "@types/node": "20.10.7", "@wdio/sauce-service": "8.27.0", "@wdio/selenium-standalone-service": "8.3.2", - "@wdio/utils": "8.27.2", + "@wdio/utils": "8.28.8", "@xmldom/xmldom": "0.8.10", "apollo-server-express": "2.25.3", "chai-as-promised": "7.1.1", From cd4288e829db7b11bd2e8e05e499a2a02b1276bb Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:52:04 +0100 Subject: [PATCH 03/19] fix: I.say would be added to Test.steps object (#4145) --- lib/actor.js | 9 ++++++--- lib/step.js | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/actor.js b/lib/actor.js index 5b4332b68..a53a03fe4 100644 --- a/lib/actor.js +++ b/lib/actor.js @@ -13,15 +13,18 @@ const output = require('./output'); */ class Actor { /** - * add print comment method` + * Print the comment on log. Also, adding a step in the `Test.steps` object * @param {string} msg * @param {string} color * @inner * * ⚠️ returns a promise which is synchronized internally by recorder */ - say(msg, color = 'cyan') { - return recorder.add(`say ${msg}`, () => { + async say(msg, color = 'cyan') { + const step = new Step('say', 'say'); + step.status = 'passed'; + return recordStep(step, [msg]).then(() => { + // this is backward compatibility as this event may be used somewhere event.emit(event.step.comment, msg); output.say(msg, `${color}`); }); diff --git a/lib/step.js b/lib/step.js index f57dc2dc8..c9184fad3 100644 --- a/lib/step.js +++ b/lib/step.js @@ -119,7 +119,9 @@ class Step { } let result; try { - result = this.helper[this.helperMethod].apply(this.helper, this.args); + if (this.helperMethod !== 'say') { + result = this.helper[this.helperMethod].apply(this.helper, this.args); + } this.setStatus('success'); } catch (err) { this.setStatus('failed'); From 439364ec0a9e0787de2a112f851599715a2538e5 Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:04:17 +0100 Subject: [PATCH 04/19] release 3.5.12 (#4156) * release 3.5.12 --- CHANGELOG.md | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +- 2 files changed, 190 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e6ccde47..02d181fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,191 @@ +## 3.5.12 + +❤️ Thanks all to those who contributed to make this release! ❤️ + +🛩️ *Features* +* feat: upgrade wdio (#4123) - by @KobeNguyenT + + 🛩️ With the release of WebdriverIO version `v8.14.0`, and onwards, all driver management hassles are now a thing of the past 🙌. Read more [here](https://webdriver.io/blog/2023/07/31/driver-management/). + One of the significant advantages of this update is that you can now get rid of any driver services you previously had to manage, such as + `wdio-chromedriver-service`, `wdio-geckodriver-service`, `wdio-edgedriver-service`, `wdio-safaridriver-service`, and even `@wdio/selenium-standalone-service`. + +For those who require custom driver options, fear not; WebDriver Helper allows you to pass in driver options through custom WebDriver configuration. +If you have a custom grid, use a cloud service, or prefer to run your own driver, there's no need to worry since WebDriver Helper will only start a driver when there are no other connection information settings like hostname or port specified. + +Example: + +```js +{ + helpers: { + WebDriver : { + smartWait: 5000, + browser: "chrome", + restart: false, + windowSize: "maximize", + timeouts: { + "script": 60000, + "page load": 10000 + } + } + } +} +``` + +Testing Chrome locally is now more convenient than ever. You can define a browser channel, and WebDriver Helper will take care of downloading the specified browser version for you. +For example: + +```js +{ + helpers: { + WebDriver : { + smartWait: 5000, + browser: "chrome", + browserVersion: '116.0.5793.0', // or 'stable', 'beta', 'dev' or 'canary' + restart: false, + windowSize: "maximize", + timeouts: { + "script": 60000, + "page load": 10000 + } + } + } +} +``` +* feat: wdio with devtools protocol (#4105) - by @KobeNguyenT + +Running with devtools protocol + +```js +{ + helpers: { + WebDriver : { + url: "http://localhost", + browser: "chrome", + devtoolsProtocol: true, + desiredCapabilities: { + chromeOptions: { + args: [ "--headless", "--disable-gpu", "--no-sandbox" ] + } + } + } + } +} +``` +* feat: add a locator builder method withTextEquals() (#4100) - by @mirao + +Find an element with exact text +```js +locate('button').withTextEquals('Add'); +``` +* feat: waitForNumberOfTabs (#4124) - by @KobeNguyenT + +Waits for number of tabs. + +```js +I.waitForNumberOfTabs(2); +``` +* feat: I.say would be added to Test.steps array (#4145) - by @KobeNguyenT + +Currently `I.say` is not added into the `Test.steps` array. This PR aims to add this to steps array so that we could use it to print steps in ReportPortal for instance. + +![Screenshot 2024-01-19 at 15 41 34](https://github.com/codeceptjs/CodeceptJS/assets/7845001/82af552a-aeb3-487e-ac10-b5bb7e42470f) + +🐛 *Bug Fixes* +* fix: reduce the package size to 2MB (#4138) - by @KobeNguyenT +* fix(webapi): see attributes on elements (#4147) - by @KobeNguyenT +* fix: some assertion methods (#4144) - by @KobeNguyenT + +Improve the error message for `seeElement`, `dontSeeElement`, `seeElementInDOM`, `dontSeeElementInDOM` + +The current error message doesn't really help when debugging issue also causes some problem described in #4140 + +Actual + +``` + expected visible elements '[ELEMENT]' to be empty + + expected - actual + + -[ + - "ELEMENT" + -] + +[] +``` + +Updated + +``` + Error: Element "h1" is still visible + at seeElementError (lib/helper/errors/ElementAssertion.js:9:9) + at Playwright.dontSeeElement (lib/helper/Playwright.js:1472:7) +``` + +* fix: css to xpath backward compatibility (#4141) - by @KobeNguyenT + +- [css-to-xpath](https://www.npmjs.com/package/css-to-xpath): old lib, which works perfectly unless you have hyphen in locator. (https://github.com/codeceptjs/CodeceptJS/issues/3563) +- [csstoxpath](https://www.npmjs.com/package/csstoxpath): new lib, to solve the issue locator with hyphen but also have some [limitations](https://www.npmjs.com/package/csstoxpath#limitations) + +* fix: grabRecordedNetworkTraffics throws error when being called twice (#4143) - by @KobeNguyenT +* fix: missing steps of test when running with workers (#4127) - by @KobeNguyenT + +```js +Scenario('Verify getting list of users', async () => { +let res = await I.getUserPerPage(2); +res.data = []; // this line causes the issue +await I.expectEqual(res.data.data[0].id, 7); +}); +``` +at this time, res.data.data[0].id would throw undefined error and somehow the test is missing all its steps. + +* fix: process.env.profile when --profile isn't set in run-multiple mode (#4131) - by @mirao + +`process.env.profile` is the string "undefined" instead of type undefined when no --profile is specified in the mode "run-multiple" + + +* fix: session doesn't respect the context options (#4111) - by @KobeNguyenT + +```js +Helpers: Playwright +Plugins: screenshotOnFail, tryTo, retryFailedStep, retryTo, eachElement + +Repro -- +[1] Starting recording promises +Timeouts: +› [Session] Starting singleton browser session +Reproduce issue +I am on page "https://example.com" +› [Browser:Error] Failed to load resource: the server responded with a status of 404 () +› [New Context] {} +user1: I am on page "https://example.com" +user1: I execute script () => { +return { width: window.screen.width, height: window.screen.height }; +} +sessionScreen is {"width":375,"height":667} +✔ OK in 1890ms + + +OK | 1 passed // 4s +``` + +* fix(plugin): retryTo issue (#4117) - by @KobeNguyenT + ![Screenshot 2024-01-08 at 17 36 54](https://github.com/codeceptjs/CodeceptJS/assets/7845001/39c97073-e2e9-4c4c-86ee-62540bc95015) + +* fix(types): CustomLocator typing broken for custom strict locators (#4120) - by @KobeNguyenT +* fix: wrong output for skipped tests - by @KobeNguyenT +* fix: no retry failed step after tryto block (#4103) - by @KobeNguyenT +* fix: deprecate some JSON Wire Protocol commands (#4104) - by @KobeNguyenT + +deprecate some JSON Wire Protocol commands: `grabGeoLocation`, `setGeoLocation` + +* fix: cannot locate complicated locator (#4101) - by @KobeNguyenT + +Locator issue due to the lib changes + +``` +The locator locate(".ps-menu-button").withText("Authoring").inside(".ps-submenu-root:nth-child(3)") is translated to +3.5.8: //*[contains(concat(' ', normalize-space(./@class), ' '), ' ps-menu-button ')][contains(., 'Authoring')][ancestor::*[(contains(concat(' ', normalize-space(./@class), ' '), ' ps-submenu-root ') and count(preceding-sibling::*) = 2)]] and works well +3.5.11: //*[contains(@class, "ps-menu-button")][contains(., 'Authoring')][ancestor::*[3][contains(@class, "ps-submenu-root")]] and doesn't work (no clickable element found). Even if you test it in browser inspector, it doesn't work. +``` + ## 3.5.11 ❤️ Thanks all to those who contributed to make this release! ❤️ diff --git a/package.json b/package.json index 9921ad3bb..a36b305d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeceptjs", - "version": "3.5.11", + "version": "3.5.12", "description": "Supercharged End 2 End Testing Framework for NodeJS", "keywords": [ "acceptance", @@ -169,4 +169,4 @@ "npm": ">=5.6.0" }, "es6": true -} +} \ No newline at end of file From 48370734cf39edc1d0c24b854435dd0dcfdfe5aa Mon Sep 17 00:00:00 2001 From: Roman Diachenko Date: Fri, 26 Jan 2024 16:38:12 +0200 Subject: [PATCH 05/19] fix(webapi): selectOption method (#4157) trim text content value --- lib/helper/Playwright.js | 2 +- .../view/form/select_additional_spaces.php | 25 +++++++++++++++++++ test/helper/webapi.js | 7 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 test/data/app/view/form/select_additional_spaces.php diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 4c0575205..4f9816cbc 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -1805,7 +1805,7 @@ class Playwright extends Helper { let optionToSelect = ''; try { - optionToSelect = await el.locator('option', { hasText: option }).textContent(); + optionToSelect = (await el.locator('option', { hasText: option }).textContent()).trim(); } catch (e) { optionToSelect = option; } diff --git a/test/data/app/view/form/select_additional_spaces.php b/test/data/app/view/form/select_additional_spaces.php new file mode 100755 index 000000000..6f202b7ac --- /dev/null +++ b/test/data/app/view/form/select_additional_spaces.php @@ -0,0 +1,25 @@ + + +
+ + + +
+ + diff --git a/test/helper/webapi.js b/test/helper/webapi.js index b8a1d2010..e50d2ffbd 100644 --- a/test/helper/webapi.js +++ b/test/helper/webapi.js @@ -433,6 +433,13 @@ module.exports.tests = function () { await I.click('Submit'); assert.deepEqual(formContents('like'), ['play', 'adult']); }); + + it('should select option by label and option text with additional spaces', async () => { + await I.amOnPage('/form/select_additional_spaces'); + await I.selectOption('Select your age', '21-60'); + await I.click('Submit'); + assert.equal(formContents('age'), 'adult'); + }); }); describe('#executeScript', () => { From 795f5d22656d5da34b84d33a5ae5a747d3cbe7f4 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 26 Jan 2024 14:39:34 +0000 Subject: [PATCH 06/19] DOC: Update contributor faces --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68dab791c..4d7ed4050 100644 --- a/README.md +++ b/README.md @@ -313,10 +313,10 @@ Thanks all to those who are and will have contributing to this awesome project! - - + + From a40285d5645faa69c9eecfe256d99d964d8c1630 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Mon, 29 Jan 2024 10:27:42 +0200 Subject: [PATCH 07/19] fixed typescript parameter inputs count --- typings/tests/helpers/Appium.types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/tests/helpers/Appium.types.ts b/typings/tests/helpers/Appium.types.ts index 1187e0d01..b2a365c10 100644 --- a/typings/tests/helpers/Appium.types.ts +++ b/typings/tests/helpers/Appium.types.ts @@ -54,7 +54,7 @@ appium.sendDeviceKeyEvent(num); // $ExpectType Promise appium.openNotifications(); // $ExpectType Promise appium.makeTouchAction(); // $ExpectType Promise appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str); // $ExpectType void +appium.performSwipe(str, str, str); // $ExpectType void appium.swipeDown(str); // $ExpectType Promise appium.swipeLeft(str); // $ExpectType Promise appium.swipeRight(str); // $ExpectType Promise From 69e0a0ef32a83c125d1d7a01fa7a139de16a76cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:58:02 +0100 Subject: [PATCH 08/19] chore(deps-dev): bump testcafe from 3.3.0 to 3.5.0 (#4160) Bumps [testcafe](https://github.com/DevExpress/testcafe) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/DevExpress/testcafe/releases) - [Changelog](https://github.com/DevExpress/testcafe/blob/master/CHANGELOG.md) - [Commits](https://github.com/DevExpress/testcafe/compare/v3.3.0...v3.5.0) --- updated-dependencies: - dependency-name: testcafe dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a36b305d9..5b3a52621 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ "runok": "0.9.3", "sinon": "17.0.1", "sinon-chai": "3.7.0", - "testcafe": "3.3.0", + "testcafe": "3.5.0", "ts-morph": "21.0.1", "ts-node": "10.9.2", "tsd-jsdoc": "2.5.0", From e117cd7349802823b5459f6e7bbbfcd88889ce21 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Tue, 23 Jan 2024 19:08:37 +0200 Subject: [PATCH 09/19] updated performSwipe with w3c protocol --- lib/helper/Appium.js | 54 ++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 2eae24a3d..93d8b4b40 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -1071,7 +1071,7 @@ class Appium extends Webdriver { onlyForApps.call(this); const res = await this.browser.$(parseLocator.call(this, locator)); // if (!res.length) throw new ElementNotFound(locator, 'was not found in UI'); - return this.performSwipe(await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); + return this.performSwipe(await res.elementId, await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); } /* eslint-enable */ @@ -1079,26 +1079,50 @@ class Appium extends Webdriver { * Perform a swipe on the screen. * * ```js - * I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 }); + * I.performSwipe(elementId, { x: 300, y: 100 }, { x: 200, y: 100 }); * ``` * + * @param {string} elementId * @param {object} from * @param {object} to * * Appium: support Android and iOS */ - async performSwipe(from, to) { - await this.browser.touchPerform([{ - action: 'press', - options: from, - }, { - action: 'wait', - options: { ms: 1000 }, - }, { - action: 'moveTo', - options: to, - }, { - action: 'release', + async performSwipe(elementId, from, to) { + await this.browser.performActions([{ + id: elementId, + type: 'pointer', + parameters: { + pointerType: 'touch', + }, + actions: [ + { + duration: 0, + x: from.x, + y: from.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerDown', + }, + { + duration: 600, + type: 'pause', + }, + { + duration: 600, + x: to.x, + y: to.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerUp', + }, + ], }]); await this.browser.pause(1000); } @@ -1128,7 +1152,7 @@ class Appium extends Webdriver { yoffset = 100; } - return this.swipe(locator, 0, yoffset, speed); + return this.swipe(parseLocator.call(this, locator), 0, yoffset, speed); } /** From ff20bc33feacda782f66b068290493e1537e38e7 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Mon, 29 Jan 2024 10:27:42 +0200 Subject: [PATCH 10/19] fixed typescript parameter inputs count --- typings/tests/helpers/Appium.types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/tests/helpers/Appium.types.ts b/typings/tests/helpers/Appium.types.ts index 1187e0d01..b2a365c10 100644 --- a/typings/tests/helpers/Appium.types.ts +++ b/typings/tests/helpers/Appium.types.ts @@ -54,7 +54,7 @@ appium.sendDeviceKeyEvent(num); // $ExpectType Promise appium.openNotifications(); // $ExpectType Promise appium.makeTouchAction(); // $ExpectType Promise appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str); // $ExpectType void +appium.performSwipe(str, str, str); // $ExpectType void appium.swipeDown(str); // $ExpectType Promise appium.swipeLeft(str); // $ExpectType Promise appium.swipeRight(str); // $ExpectType Promise From 74299252f5ea27d027f3e5d139b4b0c9412244bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 06:02:00 +0100 Subject: [PATCH 11/19] chore(deps-dev): bump @wdio/sauce-service from 8.27.0 to 8.29.1 (#4161) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b3a52621..8c2b144d8 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "@types/chai": "4.3.7", "@types/inquirer": "9.0.3", "@types/node": "20.10.7", - "@wdio/sauce-service": "8.27.0", + "@wdio/sauce-service": "8.29.1", "@wdio/selenium-standalone-service": "8.3.2", "@wdio/utils": "8.28.8", "@xmldom/xmldom": "0.8.10", From f4fed9e7755ee5efd45a9c123b4d92cd3267c454 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Tue, 30 Jan 2024 11:31:11 +0200 Subject: [PATCH 12/19] removed elementId parameter --- lib/helper/Appium.js | 10 +++++----- typings/tests/helpers/Appium.types.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 93d8b4b40..81fcfa415 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -2,6 +2,7 @@ let webdriverio; const fs = require('fs'); const axios = require('axios').default; +const { v4: uuidv4 } = require('uuid'); const Webdriver = require('./WebDriver'); const AssertionFailedError = require('../assert/error'); @@ -1071,7 +1072,7 @@ class Appium extends Webdriver { onlyForApps.call(this); const res = await this.browser.$(parseLocator.call(this, locator)); // if (!res.length) throw new ElementNotFound(locator, 'was not found in UI'); - return this.performSwipe(await res.elementId, await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); + return this.performSwipe(await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); } /* eslint-enable */ @@ -1079,18 +1080,17 @@ class Appium extends Webdriver { * Perform a swipe on the screen. * * ```js - * I.performSwipe(elementId, { x: 300, y: 100 }, { x: 200, y: 100 }); + * I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 }); * ``` * - * @param {string} elementId * @param {object} from * @param {object} to * * Appium: support Android and iOS */ - async performSwipe(elementId, from, to) { + async performSwipe(from, to) { await this.browser.performActions([{ - id: elementId, + id: uuidv4(), type: 'pointer', parameters: { pointerType: 'touch', diff --git a/typings/tests/helpers/Appium.types.ts b/typings/tests/helpers/Appium.types.ts index b2a365c10..1187e0d01 100644 --- a/typings/tests/helpers/Appium.types.ts +++ b/typings/tests/helpers/Appium.types.ts @@ -54,7 +54,7 @@ appium.sendDeviceKeyEvent(num); // $ExpectType Promise appium.openNotifications(); // $ExpectType Promise appium.makeTouchAction(); // $ExpectType Promise appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str, str); // $ExpectType void +appium.performSwipe(str, str); // $ExpectType void appium.swipeDown(str); // $ExpectType Promise appium.swipeLeft(str); // $ExpectType Promise appium.swipeRight(str); // $ExpectType Promise From feb8d52a1e8a2e7a4a478ab84840b82c5bd8ffb6 Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Tue, 23 Jan 2024 19:08:37 +0200 Subject: [PATCH 13/19] updated performSwipe with w3c protocol --- lib/helper/Appium.js | 54 ++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 2eae24a3d..93d8b4b40 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -1071,7 +1071,7 @@ class Appium extends Webdriver { onlyForApps.call(this); const res = await this.browser.$(parseLocator.call(this, locator)); // if (!res.length) throw new ElementNotFound(locator, 'was not found in UI'); - return this.performSwipe(await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); + return this.performSwipe(await res.elementId, await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); } /* eslint-enable */ @@ -1079,26 +1079,50 @@ class Appium extends Webdriver { * Perform a swipe on the screen. * * ```js - * I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 }); + * I.performSwipe(elementId, { x: 300, y: 100 }, { x: 200, y: 100 }); * ``` * + * @param {string} elementId * @param {object} from * @param {object} to * * Appium: support Android and iOS */ - async performSwipe(from, to) { - await this.browser.touchPerform([{ - action: 'press', - options: from, - }, { - action: 'wait', - options: { ms: 1000 }, - }, { - action: 'moveTo', - options: to, - }, { - action: 'release', + async performSwipe(elementId, from, to) { + await this.browser.performActions([{ + id: elementId, + type: 'pointer', + parameters: { + pointerType: 'touch', + }, + actions: [ + { + duration: 0, + x: from.x, + y: from.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerDown', + }, + { + duration: 600, + type: 'pause', + }, + { + duration: 600, + x: to.x, + y: to.y, + type: 'pointerMove', + origin: 'viewport', + }, + { + button: 1, + type: 'pointerUp', + }, + ], }]); await this.browser.pause(1000); } @@ -1128,7 +1152,7 @@ class Appium extends Webdriver { yoffset = 100; } - return this.swipe(locator, 0, yoffset, speed); + return this.swipe(parseLocator.call(this, locator), 0, yoffset, speed); } /** From f914416fdd166aafac58f3c31b1e83c27b93ec8b Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Mon, 29 Jan 2024 10:27:42 +0200 Subject: [PATCH 14/19] fixed typescript parameter inputs count --- typings/tests/helpers/Appium.types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/tests/helpers/Appium.types.ts b/typings/tests/helpers/Appium.types.ts index 1187e0d01..b2a365c10 100644 --- a/typings/tests/helpers/Appium.types.ts +++ b/typings/tests/helpers/Appium.types.ts @@ -54,7 +54,7 @@ appium.sendDeviceKeyEvent(num); // $ExpectType Promise appium.openNotifications(); // $ExpectType Promise appium.makeTouchAction(); // $ExpectType Promise appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str); // $ExpectType void +appium.performSwipe(str, str, str); // $ExpectType void appium.swipeDown(str); // $ExpectType Promise appium.swipeLeft(str); // $ExpectType Promise appium.swipeRight(str); // $ExpectType Promise From a42f717959f7a20f989ae3f042da197aefff84bc Mon Sep 17 00:00:00 2001 From: Mykhailo Levchun Date: Tue, 30 Jan 2024 11:31:11 +0200 Subject: [PATCH 15/19] removed elementId parameter --- lib/helper/Appium.js | 10 +++++----- typings/tests/helpers/Appium.types.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 93d8b4b40..81fcfa415 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -2,6 +2,7 @@ let webdriverio; const fs = require('fs'); const axios = require('axios').default; +const { v4: uuidv4 } = require('uuid'); const Webdriver = require('./WebDriver'); const AssertionFailedError = require('../assert/error'); @@ -1071,7 +1072,7 @@ class Appium extends Webdriver { onlyForApps.call(this); const res = await this.browser.$(parseLocator.call(this, locator)); // if (!res.length) throw new ElementNotFound(locator, 'was not found in UI'); - return this.performSwipe(await res.elementId, await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); + return this.performSwipe(await res.getLocation(), { x: (await res.getLocation()).x + xoffset, y: (await res.getLocation()).y + yoffset }); } /* eslint-enable */ @@ -1079,18 +1080,17 @@ class Appium extends Webdriver { * Perform a swipe on the screen. * * ```js - * I.performSwipe(elementId, { x: 300, y: 100 }, { x: 200, y: 100 }); + * I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 }); * ``` * - * @param {string} elementId * @param {object} from * @param {object} to * * Appium: support Android and iOS */ - async performSwipe(elementId, from, to) { + async performSwipe(from, to) { await this.browser.performActions([{ - id: elementId, + id: uuidv4(), type: 'pointer', parameters: { pointerType: 'touch', diff --git a/typings/tests/helpers/Appium.types.ts b/typings/tests/helpers/Appium.types.ts index b2a365c10..1187e0d01 100644 --- a/typings/tests/helpers/Appium.types.ts +++ b/typings/tests/helpers/Appium.types.ts @@ -54,7 +54,7 @@ appium.sendDeviceKeyEvent(num); // $ExpectType Promise appium.openNotifications(); // $ExpectType Promise appium.makeTouchAction(); // $ExpectType Promise appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str, str); // $ExpectType void +appium.performSwipe(str, str); // $ExpectType void appium.swipeDown(str); // $ExpectType Promise appium.swipeLeft(str); // $ExpectType Promise appium.swipeRight(str); // $ExpectType Promise From eb1d5d4e8fe23553c91650a5b06edbaf8c8f7cb7 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Jan 2024 11:34:25 +0100 Subject: [PATCH 16/19] run mobile tests --- .github/workflows/appiumV2_Android.yml | 1 + .github/workflows/appiumV2_iOS.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/appiumV2_Android.yml b/.github/workflows/appiumV2_Android.yml index 2fa1098c4..627b620aa 100644 --- a/.github/workflows/appiumV2_Android.yml +++ b/.github/workflows/appiumV2_Android.yml @@ -4,6 +4,7 @@ on: push: branches: - 3.x + - MykaLev:performeSwipe-updated-to-w3c-protocol env: CI: true diff --git a/.github/workflows/appiumV2_iOS.yml b/.github/workflows/appiumV2_iOS.yml index 6c9f46549..53093f067 100644 --- a/.github/workflows/appiumV2_iOS.yml +++ b/.github/workflows/appiumV2_iOS.yml @@ -4,6 +4,7 @@ on: push: branches: - 3.x + - MykaLev:performeSwipe-updated-to-w3c-protocol env: CI: true From 1cc4f434ca5b6b95f435d7ab1ef2f6c8f7ea9f97 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Jan 2024 11:36:14 +0100 Subject: [PATCH 17/19] run mobile tests --- .github/workflows/appiumV2_Android.yml | 2 +- .github/workflows/appiumV2_iOS.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/appiumV2_Android.yml b/.github/workflows/appiumV2_Android.yml index 627b620aa..5068ae1b2 100644 --- a/.github/workflows/appiumV2_Android.yml +++ b/.github/workflows/appiumV2_Android.yml @@ -4,7 +4,7 @@ on: push: branches: - 3.x - - MykaLev:performeSwipe-updated-to-w3c-protocol + - '**' env: CI: true diff --git a/.github/workflows/appiumV2_iOS.yml b/.github/workflows/appiumV2_iOS.yml index 53093f067..49de5e5b4 100644 --- a/.github/workflows/appiumV2_iOS.yml +++ b/.github/workflows/appiumV2_iOS.yml @@ -4,7 +4,7 @@ on: push: branches: - 3.x - - MykaLev:performeSwipe-updated-to-w3c-protocol + - '**' env: CI: true From 40a117ce03c3a1f89974e87d6e714e0e20b19745 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Jan 2024 11:37:44 +0100 Subject: [PATCH 18/19] run mobile tests --- .github/workflows/appiumV2_Android.yml | 2 ++ .github/workflows/appiumV2_iOS.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/appiumV2_Android.yml b/.github/workflows/appiumV2_Android.yml index 5068ae1b2..acebf04cf 100644 --- a/.github/workflows/appiumV2_Android.yml +++ b/.github/workflows/appiumV2_Android.yml @@ -4,6 +4,8 @@ on: push: branches: - 3.x + pull_request: + branches: - '**' env: diff --git a/.github/workflows/appiumV2_iOS.yml b/.github/workflows/appiumV2_iOS.yml index 49de5e5b4..ecd274259 100644 --- a/.github/workflows/appiumV2_iOS.yml +++ b/.github/workflows/appiumV2_iOS.yml @@ -4,6 +4,8 @@ on: push: branches: - 3.x + pull_request: + branches: - '**' env: From 116d6557f20bb697f634161e08a7a97d8e1ef08f Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Jan 2024 13:57:37 +0100 Subject: [PATCH 19/19] tweak ci --- .github/workflows/appiumV2_Android.yml | 3 --- .github/workflows/appiumV2_iOS.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/appiumV2_Android.yml b/.github/workflows/appiumV2_Android.yml index acebf04cf..2fa1098c4 100644 --- a/.github/workflows/appiumV2_Android.yml +++ b/.github/workflows/appiumV2_Android.yml @@ -4,9 +4,6 @@ on: push: branches: - 3.x - pull_request: - branches: - - '**' env: CI: true diff --git a/.github/workflows/appiumV2_iOS.yml b/.github/workflows/appiumV2_iOS.yml index ecd274259..6c9f46549 100644 --- a/.github/workflows/appiumV2_iOS.yml +++ b/.github/workflows/appiumV2_iOS.yml @@ -4,9 +4,6 @@ on: push: branches: - 3.x - pull_request: - branches: - - '**' env: CI: true