Skip to content
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

Incorrect enabled prop from getAttributes() in Detox for disabled elements #4644

Open
1 of 2 tasks
erdemkiiliic opened this issue Nov 26, 2024 · 0 comments
Open
1 of 2 tasks

Comments

@erdemkiiliic
Copy link

erdemkiiliic commented Nov 26, 2024

What happened?

I am encountering an issue with getAttributes() where the enabled property of an element is being returned incorrectly. I have confirmed that this occurs on both Android and iOS. Using Appium Inspector and Layout Inspector, I verified that the element associated with this testID is disabled at that moment, but I cannot validate this with Detox. Could this be a bug, or am I possibly checking the enabled state for an incorrect view?

Appium inspector:
Screenshot 2024-11-26 at 19 19 45

What was the expected behaviour?

In this example, my expectation is for the enabled property to return false.

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

  1. Create a view with a disabled element:
    • Add a UI component (e.g., a button or input field) that starts in a disabled state.
    • Assign a unique testID to this element.
  2. Verify the element is disabled using a visual tool:
    • Use Appium Inspector or Layout Inspector to confirm the element is indeed disabled.
  3. Write a Detox test:
    • Write a test using Detox’s getAttributes() method to check the enabled property of the element with the assigned testID.
  4. Run the test:
    • Execute the test on both Android and iOS.
  5. Compare results:
    • Observe the value returned by getAttributes() for the enabled property and compare it with the expected false.

In what environment did this happen?

Detox version: 20.28.0
React Native version: 0.72.5
Has Fabric (React Native's new rendering system) enabled: no
Node version: 18.20.4
Device model: Pixel 7a
Android version: Android 15.0 arm64-v8a
Test-runner: jest

Detox logs

Detox logs for getAttributes() console.log(JSON.stringify(await element(by.id(ElementIds.HamburgerMenu.operationSection)).getAttributes(), null, 2))
{
  "identifier": "common.hamburger.section.operation",
  "visibility": "visible",
  "visible": true,
  "label": "undefined.rnText",
  "alpha": 1,
  "elevation": 0,
  "frame": {
    "x": 0,
    "y": 377,
    "width": 912,
    "height": 147
  },
  "height": 147,
  "width": 912,
  "focused": false,
  "enabled": true
}

Device logs

Device logs
11-27 02:15:59.263 30901 30956 D DetoxWSClient: Received action 'invoke' (ID #14, params={"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["common.hamburger.section.operation",{"type":"boolean","value":false}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAction"},"method":"getAttributes","args":[]}}]})
11-27 02:15:59.263 30901 30952 I DetoxDispatcher: Handling action 'invoke' (ID #14)...
11-27 02:15:59.263 30901 30952 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [common.hamburger.section.operation, false]
11-27 02:15:59.264 30901 30952 D Detox   : class com.wix.detox.espresso.DetoxAction, getAttributes, []
11-27 02:15:59.264 30901 30952 D Detox   : class com.wix.detox.espresso.EspressoDetox, perform, [(view.getTag() is "common.hamburger.section.operation" and view has effective visibility <VISIBLE>), com.wix.detox.espresso.action.GetAttributesAction@768985b]
11-27 02:15:59.266 30901 30901 I ViewInteraction: Performing 'Get view attributes' action on view View at index #0, of those matching MATCHER(view.getTag() is "common.hamburger.section.operation" and view has effective visibility <VISIBLE>)
11-27 02:15:59.282 30901 30952 I UiAutomation: Initialized for user 0 on display 0
11-27 02:15:59.286   561  4265 D AccessibilityManagerService: changeCurrentUserForTestAutomationIfNeededLocked(0): ignoring because device doesn't support visible background users
11-27 02:15:59.286   561  4265 I UiAutomationManager: Registering UiTestAutomationService (id=com.android.server.accessibility/UiAutomation) when called by user 0
11-27 02:15:59.289 30901 30952 W DefaultFailureHandler: Failed to take screenshot

More data, please!

When I use with await enabled is always true

await element(by.id(ElementIds.HamburgerMenu.operationSection)).getAttributes();

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant