Detox icon indicating copy to clipboard operation
Detox copied to clipboard

Retrieve isChecked attribute with getAttributes() method

Open sergtimosh opened this issue 3 years ago • 9 comments

Is your feature request related to a problem? Please describe. This particular case is Android specific. In my tests I rely on such attributes like 'is-checked' for toggle value, another attributes are used for button state - enabled/disabled which currently ommited in the returning object of getAttributes() method. The only way to retrieve this values is parsing error object like it's being described here

Describe the solution you'd like Yield more attribute-value pairs from the element to extend potential checks.

image

sergtimosh avatar Jan 05 '22 09:01 sergtimosh

@sergtimosh please revisit our documentation about getAttributes. I think props such as enabled and value might be what you're looking for.

d4vidi avatar Jan 05 '22 15:01 d4vidi

@d4vidi, unfortunately value is relevant only for the iOS version of the app. In order to achieve the same on Android the only option is is-checked for my case. Properties from android element: { identifier: 'header-results-toggle', visibility: 'visible', visible: true, alpha: 1, elevation: 0, height: 74, width: 128, focused: false, enabled: true, text: '', length: 0, textSize: 39 }

sergtimosh avatar Jan 05 '22 17:01 sergtimosh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

stale[bot] avatar Feb 05 '22 02:02 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Feb 12 '22 06:02 stale[bot]

Bump, this would be really helpful

owens-ben avatar Jan 03 '23 20:01 owens-ben

@asafkorem could you look what extras could be exposed on iOS side, please?

noomorph avatar Jan 11 '23 14:01 noomorph

@asafkorem could you look what extras could be exposed on iOS side, please?

Already did @noomorph, in the corresponding issue for iOS attributes 🙂 https://github.com/wix/Detox/issues/3116#issuecomment-982008651

asafkorem avatar Jan 11 '23 15:01 asafkorem

Legit. Let's try to leave the discussion on extra attributes to #3116. I'll take a glance at the fix-potential for Android for this specifically, in a bit.

d4vidi avatar Jan 12 '23 10:01 d4vidi

So while we do consider the isChecked property of an Android view in getAttributes(), we seem to limit ourselves to CheckBox views. The proper fix here is likely to extend things to any Checkable, which CheckBox implements anyways.

BTW, seems like there are a ton of other classes that do this, so it would be a good idea to also skim through in order to make sure all associated views are also relevant:

image

So to sum things up, in order to fix this, we need to:

  1. Extend the value property to match any Checkable. We need to do this in an override-able way, meaning, that if a class holds some other meaningful attribute that is more tightly associated with the concept of value (e.g. a checkable text view), it should make usage of value for it.
  2. Apply more view types (e.g. toggles, such as specified by the OP) in the E2E tests we have for this, at least on Android.

d4vidi avatar Jan 12 '23 10:01 d4vidi