Detox: SwiftUI Element matchers, visibility & actions (like tap) not working with detox 18.x

Description

Detox 18.x can’t seem to match, view & interact with swiftUI elements.

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

Reproduction

I found this closed issue in detox issues regarding swiftUI & forked this sample repo from there & added jest support for better logs, I also added an action to the button in that repo to show an alert & added a tap acton in detox tests.

Please see this repo for reproducing the issue, I have created branches for detox version 17.14.9 , 18.0.0 , 18.3.1 for test convenience.

  • Basically with version 17.14.9 detox can see the button & click it too (but after that it seems to be waiting on some event to sync up, have included test run logs below with debug-sync) & thus never runs the next step & fails

  • With version 18.0.0 & 18.3.1 , detox doesn’t seem to even see the button & is also unable to tap it (I even tried disableSync & no luck sadly).

  • Adding steps to reproduce below

  1. Run npm install
  2. Run npm run detox:ios:build
  3. Run npm run detox:ios:test (added various debug flags for convenience)

Please let me know if you need any more info 🙏🏼, also great work with detox!

Expected behavior

Detox should be able to match, view SwiftUI elements & interact with them

Screenshots

I have attached videos of the full test runs below for detox-17.14.9 & detox-18.3.1 (notice on 17.14.9 it sees the button & taps it as the alert pops up , but with version 18.3.1 it can’t even see the button)

Environment (please complete the following information):

  • Detox: 18.3.1
  • Node: v10.14.1
  • Device: iPhone 11 Pro
  • Xcode: Version 12.4 (12D4e)
  • iOS: 14.4
  • macOS: 11.2 (Big Sur)

Logs

If you are experiencing a timeout in your test

Device and verbose Detox logs

  • I have run my tests using the --loglevel trace argument and am providing the verbose log below:

Please see the logs of test run with various detox versions below

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@alon-ha, I’ll remove stale label, if you don’t mind.

https://github.com/wix/Detox/pull/2638

With this fix, your suite passes.

This issue is quite old, and unfortunately, we do not have the resources to support non-React-Native / SwiftUI apps at the moment. While it is possible to embed SwiftUI components within a UIKit container, it is not a common practice within the React-Native community.

As there have been no updates or requests for support on this issue for over a year, and it is a community requirement, I will be closing this issue. If anyone has any objections or concerns, we can re-open this issue or start another one for further discussion…

This issue thrown me off when I setup Detox. The basic e2e test work fine for Android but not for iOS.

The only work around is using testID to query element, which is a big turn off since I’m trying to writing the tests from user perspective.

How I can tap on button from Alert on IOS? Now because of this I can’t find alert button by text and all my tests fails

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.

Thanks for the detailed report. Indeed, that makes more sense; Detox 18 uses a new synchronization mechanism. I’ll check out the demo project soon to try to figure out what’s going on.