In my test, I would like to simulate a tap in the "cancelUpgrade" button only if it is displayed:
it('should be in home menu', async () => {
await waitFor(element(by.id('cancelUpgrade')))
.toBeVisible()
.withTimeout(2000);
await element(by.id('cancelUpgrade')).tap();
});
It returns the expected error Error: Cannot find UI element.
https://github.com/wix/detox
You can wrap tap in the try/catch block:
it('should be in home menu', async () => {
await waitFor(element(by.id('cancelUpgrade')))
.toBeVisible()
.withTimeout(2000);
try {
await element(by.id('cancelUpgrade')).tap();
} catch (e) {}
// continue your tests
});
Not the best way but i think that's what currently possible within detox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With