-
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
Be able to check if element is tappable/clickable #246
Comments
try {
await expect(element(by.id(`MY_BUTTON`))).tap();
console.log('Tappable!')
} catch (e) {
console.log('Not tappable')
} |
@isnifer Thanks, I've tried it before, and I get an exception if the element is disabled and I try to tap on it: |
@gran33 try-catch will help you do not throw an exception. Can you show me full error part of the log? |
|
@gran33 is this a button from navigation bar? Is it enabled? |
@isnifer Yes, the button is navigation bar button. It disabled and I want to e2e test that the button is disabled. |
@gran33 So, what happens if the user clicks on the enabled button? Transition to another screen? |
@isnifer After I press the button a Modal screen should be dismissed, but the point that I cannot test if the button is enabled or disabled. |
@gran33 ok, got it. try {
await element(by.id(`MY_BUTTON`)).tap() // <= it will fail here if button disabled
await expect(element(by.id(`MY_BUTTON`))).toBeNotVisible() // and will work fine if enabled
console.log('Modal should be hidden') // <= change console.log to any assertion from your test library (mocha, tape, jest, etc...)
} catch (e) {
console.log('Button should be disabled')
} |
Thanks, it seems to be working. Thanks again for your time and for the example 🙏 |
@gran33 you're welcome. You may like or dislike, but try-catch is a powerful mechanism. You can write your own helpers to make your tests code more readable and efficient. |
@DanielZlotin really? What reasons? |
@isnifer well, for example, what if the button is not there at all? what if the button does something to crash the app? etc. etc. Why go that hacky path if you already have support for this exact thing? |
more importantly, in detox the errors usually occur in native, which means you'll have your exception in |
|
There are a lot of assumptions here. |
Book about TDD. I think it’s the main problem that people compare TDD and E2E. They are different things |
detox is a wrapper around EralGrey and Espresso, e2e testing tools. Your professionalism is your own choice, but detox should provide any and all tooling necessary for doing e2e (TDD or otherwise) using those tools. |
@DanielZlotin @rotemmiz Is there a plan to export |
Not something that can be easily implemented. |
Description
I would like to be able to check if element is tappable/clickable in order to
expect
on element totappable/clickable
.Steps to Reproduce
My dream is to be able to do something like this:
await expect(element(by.id(`MY_BUTTON`))).toBeTappable();
The text was updated successfully, but these errors were encountered: