Skip to content

fix: updated performSwipe with w3c protocol #4154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7f43984
updated performSwipe with w3c protocol
MykaLev Jan 23, 2024
a445b71
chore(deps-dev): bump @wdio/utils from 8.27.2 to 8.28.8 (#4152)
dependabot[bot] Jan 25, 2024
cd4288e
fix: I.say would be added to Test.steps object (#4145)
kobenguyent Jan 25, 2024
439364e
release 3.5.12 (#4156)
kobenguyent Jan 25, 2024
4837073
fix(webapi): selectOption method (#4157)
dyaroman Jan 26, 2024
795f5d2
DOC: Update contributor faces
actions-user Jan 26, 2024
a40285d
fixed typescript parameter inputs count
MykaLev Jan 29, 2024
69e0a0e
chore(deps-dev): bump testcafe from 3.3.0 to 3.5.0 (#4160)
dependabot[bot] Jan 29, 2024
e117cd7
updated performSwipe with w3c protocol
MykaLev Jan 23, 2024
ff20bc3
fixed typescript parameter inputs count
MykaLev Jan 29, 2024
f31ab61
Merge remote-tracking branch 'origin/performeSwipe-updated-to-w3c-pro…
MykaLev Jan 29, 2024
7429925
chore(deps-dev): bump @wdio/sauce-service from 8.27.0 to 8.29.1 (#4161)
dependabot[bot] Jan 30, 2024
f4fed9e
removed elementId parameter
MykaLev Jan 30, 2024
feb8d52
updated performSwipe with w3c protocol
MykaLev Jan 23, 2024
f914416
fixed typescript parameter inputs count
MykaLev Jan 29, 2024
a42f717
removed elementId parameter
MykaLev Jan 30, 2024
4b02f89
Merge remote-tracking branch 'origin/performeSwipe-updated-to-w3c-pro…
MykaLev Jan 30, 2024
eb1d5d4
run mobile tests
kobenguyent Jan 30, 2024
1cc4f43
run mobile tests
kobenguyent Jan 30, 2024
40a117c
run mobile tests
kobenguyent Jan 30, 2024
116d655
tweak ci
kobenguyent Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 39 additions & 15 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,34 +1071,58 @@ 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 */

/**
* 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 });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to performSwipe without passing the elementId?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id: - is mandatory attribute of the w3c call. But can be used some random string inside the method instead of elementId parameter

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll be great if we could implement like that. Cause we actually perform swipe without knowing any element id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed elementId but after merge after sync with main repo I got some extra files changes. Not sure why

* ```
*
* @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);
}
Expand Down Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion typings/tests/helpers/Appium.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ appium.sendDeviceKeyEvent(num); // $ExpectType Promise<void>
appium.openNotifications(); // $ExpectType Promise<void>
appium.makeTouchAction(); // $ExpectType Promise<void>
appium.tap(str); // $ExpectType Promise<void>
appium.performSwipe(str, str); // $ExpectType void
appium.performSwipe(str, str, str); // $ExpectType void
appium.swipeDown(str); // $ExpectType Promise<void>
appium.swipeLeft(str); // $ExpectType Promise<void>
appium.swipeRight(str); // $ExpectType Promise<void>
Expand Down