SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 742 forks source link

Elements inside MaskingView can not be accessed through XCUIApplication #407

Closed skheirandish closed 3 years ago

skheirandish commented 3 years ago

This is as far as I can print in the hierarchy:

 Window (Main), 0x6000035589a0, {{0.0, 0.0}, {414.0, 896.0}}, identifier: 'SwiftMessages.PassthroughWindow'
      Other, 0x600003558a80, {{0.0, 0.0}, {414.0, 896.0}}
         Other, 0x600003558b60, {{0.0, 0.0}, {414.0, 896.0}}
           Other, 0x600003558c40, {{0.0, 0.0}, {414.0, 896.0}}, identifier: 'SwiftMessages.PassthroughView'
             Other, 0x600003558d20, {{0.0, 0.0}, {414.0, 896.0}}, identifier: 'SwiftMessages.MaskingView' 

I have labeled those views for better understanding of where it stops printing.

wtmoose commented 3 years ago

Could you elaborate please?

skheirandish commented 3 years ago

When I print the XCUIApplication in debug panel I can't see elements inside MaskingView. All the subviews are not accessible. I have looked at the hierarchy and it seems that all container views are not accessible elements (which is the way it should be) and all my subviews, UILabels and UIButtons are accessible elements.

Basically it looks right but ultimately the view thats being presented is not in the XCUIApplication hierarchy so I cant find it for my tests.

In this image none of these views are accessibility elements but inside the very last view (ToastView) there are UILabels and UIButtons that are accessibility elements. image

I need to be able to see some StaticTexts and some OtherElements inside XCUIApplication but i cant.

wtmoose commented 3 years ago

SwiftMessages had enhanced accessibility features. As part of this, MaskingView is an accessibility container. Your view needs to adopt AccessibleMessage to integrate properly with this system. My suggestions are:

  1. Read the Accessibility section in the Readme
  2. Refer to references to AccessibleMessage in Presenter to understand how it is used.
  3. Refer to references to AccessibleMessage in MessageView to understand how to adopt the protocol.

Hope that helps.

skheirandish commented 3 years ago

Perfect, following the sample in MessageView helped me. Thank you.