-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(android): add device.tap()
and device.longPress()
.
#4534
Conversation
device.tap()
and device.longPress()
.
@gayablau please fix the lint errors and unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👏🏼 🤩
We also need to document this (device.md
).
async tap(point) { | ||
return ''; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a similar method for longPress(arg1, arg2)
(in DeviceDriverBase.js
).
detox/test/e2e/06.device.test.js
Outdated
it(':android: tap on screen', async () => { | ||
await device.launchApp({ newInstance: true }); | ||
await element(by.text('Device Tap')).tap(); | ||
await device.tap(); | ||
await expect(element(by.text('Screen Tapped'))).toBeVisible(); | ||
}); | ||
|
||
it(':android: tap on screen by coordinates', async () => { | ||
await device.launchApp({ newInstance: true }); | ||
await element(by.text('Device Tap')).tap(); | ||
const point = {x: 200, y: 243} | ||
await device.tap(point); | ||
await expect(element(by.text('Button Tapped'))).toBeVisible(); | ||
}); | ||
|
||
it(':android: long press on screen by coordinates', async () => { | ||
await device.launchApp({ newInstance: true }); | ||
await element(by.text('Device Tap')).tap(); | ||
const point = {x: 150, y: 300} | ||
await device.longPress(point); | ||
await expect(element(by.text('Screen Long Pressed'))).toBeVisible(); | ||
}); | ||
|
||
it(':android: long press on screen by coordinates with duration', async () => { | ||
await device.launchApp({ newInstance: true }); | ||
await element(by.text('Device Tap')).tap(); | ||
const point = {x: 200, y: 190} | ||
await device.longPress(point, 2000); | ||
await expect(element(by.text('Screen Long Custom Duration Pressed'))).toBeVisible(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's extract these to a new suite (e.g. 06.device-tap.test.js
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add e2e tests for long-press with (1) duration only and (2) no params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also add more tests:
should long press on specified point
(expect for specific area to be pressed when passing thepoint
param)should not succeed in long pressing with point outside the target area
Check how we added a similar tests on 03.actions.test.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for device.tap(point)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about the spetific point test these are tap on button by coordinates ignoring status bar
and long press on button by coordinates with duration ignoring status bar
. about failing on press outside the are these are long press on screen with duration without specifying coordinates
and tap on screen without specifying coordinates
tell me if It is what you meant
async tap(point) { | ||
let x = point?.x || 100; | ||
let y = point?.y || 100; | ||
const call = EspressoDetoxApi.tap(x, y); | ||
await this.invocationManager.execute(call); | ||
} | ||
|
||
async longPress(point, duration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the relevant unit tests (androiddriver.test.js
)
Also let's add assertion when calling this API on iOS (raise unsupported message) - we should have that until adding the support on iOS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Work!
Please fix the tests and the lint
united android and ios branches. fixes of review pushed to #4542 |
Description
In this pull request, I have …