How do you interact with OS specific pop-ups in UI testing?

I am trying to UI Test a cross-platform application that gets permission to the device's camera. To do so, it pulls up a pop-up box where the user must "ALLOW" or "DENY" access to the camera. How can I interact with this pop-up in my UI tests?


  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    Answer from @MatthewRegul from this post. NOt everyone can access that forum so copying answer below:

    This should help you get started...

    Query for the Alert Control
    iOS :: app.Query(c=>c.ClassFull("_UIAlertControllerView"))
    Android :: app.Query(c => c.Class("AlertDialogLayout"))

    Query for the OK button on the Alert Control
    iOS :: app.Query(c=>c.Marked("OK").Parent().ClassFull("_UIAlertControllerView"))
    Android :: app.Query(c=>c.Marked("OK").Parent().Class("AlertDialogLayout"))

    Code Sample -

    Additional Resources:
    1. Working with Repl -
    2. Test Recorder -
    3. (more) Test Recorder -
    4. Query Child Walk-up -

    iOS Tree

    [CalabashRootView > UIWindow]                                                   
        [UIView > ... > Xamarin_Forms_Platform_iOS_LabelRenderer]
            [UILabel] label: "Welcome to Xamarin Forms!",  text: "Welcome to Xamarin Forms!"
            [_UIAlertControllerView > ... > _UIAlertControllerInterfaceActionGroupView] label: "Title"
                    [_UIInterfaceActionGroupHeaderScrollView > UIView]
                        [UILabel] label: "Title",  text: "Title"
                        [UILabel] label: "Message",  text: "Message"
                    [_UIInterfaceActionItemSeparatorView_iOS > UIView]
                    [_UIInterfaceActionRepresentationsSequenceView > ... > _UIInterfaceActionCustomViewRepresentationView]
                        [_UIAlertControllerActionView > UIView] label: "OK"
                            [UILabel] label: "OK",  text: "OK"

    Android Tree

    [[object CalabashRootView]]
        [PhoneWindow$DecorView > ... > FrameLayout]
            [FitWindowsFrameLayout] id: "action_bar_root"
                [ContentFrameLayout] id: "content"
                    [AlertDialogLayout] id: "parentPanel"
                        [LinearLayout] id: "topPanel"
                            [LinearLayout] id: "title_template"
                                [DialogTitle] id: "alertTitle" text: "Title"
                            [Space] id: "titleDividerNoCustom"
                        [FrameLayout] id: "contentPanel"
                            [NestedScrollView > LinearLayout] id: "scrollView"
                                [AppCompatTextView] id: "message" text: "Message"
                        [ScrollView > ButtonBarLayout] id: "buttonPanel"
                            [AppCompatButton] id: "button2" text: "OK"
        [LinearLayout > FrameLayout]
            [FitWindowsFrameLayout] id: "action_bar_root"
                [ContentFrameLayout > RelativeLayout] id: "content"
                        [NavigationPageRenderer] id: "NoResourceEntry-1"
                            [PageContainer > ... > LabelRenderer]
                                [FormsTextView] text: "Welcome to Xamarin Forms!"
                            [Toolbar] id: "toolbar"
                                [AppCompatTextView] text: "DisplayAlertUITest"
        [View] id: "navigationBarBackground"
  • hkiddhkidd Member ✭✭

    @JGoldberger Thank you!

    Disclaimer: This only works with application-contained dialog alerts. It does NOT work with OS-generated popups, such as those produced when asking permission to the camera, etc.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Ah, sorry.

    According to this thread, those should be auto accepted:

    You may want to reach out to App Center support if they are not:

  • hkiddhkidd Member ✭✭

    @JGoldberger No worries! Thanks for your help. Yeah - they are currently not auto-accepted, but I am developing in a cross-platform app using .NET 2.0 Standard so that could be part of the issue. Thanks again!

Sign In or Register to comment.