How to tap "ALLOW" or "DENY" on the access pop up using UI tests?

I dont even know how to do this.
I tried:
app.Tap(c => c.Text("ALLOW"));
app.Tap(c => c.Marked("ALLOW"));
app.Tap(c => c.Button("ALLOW"));

How to do this guys?

Answers

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    Do REPL and check what's the Id of that button using 'tree' command, Use that Id.

  • alekssmykalekssmyk USMember ✭✭✭
    edited June 2017

    @ShantimohanElchuri Thank you for this command. I can see only the elements from my page, but not from the system pop up dialog. Here is what I get from the tree command:
    [[object CalabashRootView] > ... > FrameLayout]
    [FitWindowsFrameLayout] id: "action_bar_root"
    [ContentFrameLayout > RelativeLayout] id: "content"
    [View]
    [PlatformRenderer]
    [CustomNavigationRenderer > ... > Platform_DefaultRenderer] id: "NoResourceEntry-2"
    [Platform_DefaultRenderer > ... > CachedImageView]
    [FontAwareLabelRenderer]
    [FormsTextView] text: "1/20"
    [ExCarouselViewRenderer > ... > CachedImageView]
    [Platform_DefaultRenderer > Platform_DefaultRenderer]
    [Platform_DefaultRenderer]
    [Platform_DefaultRenderer > ... > CachedImageView] label: "record"
    [Platform_DefaultRenderer > ... > CachedImageView]

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @alekssmyk Can you post a screen shot? Or better if you can post the XAML or code that builds your UI?

  • alekssmykalekssmyk USMember ✭✭✭

    @ShantimohanElchuri Here is what I try to tap:

    It is a standard system dialog when you first try to access microphone to record an audio.

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @alekssmyk I tried your issue over the weekend. I have not tried accessing the microphone but with sending an SMS (because I had that code readily). But it appears that may not be the correct way to resolve your issue.

    When I tried to send an SMS, even on an emulator, it opened a screen for me to type in message and set a phone number. I couldn't access the Send button on this page. When I did the 'tree' command all that I got was "[CalabashRoot]".

    So I will have to try different example.

  • DevinGuthrieDevinGuthrie USMember ✭✭

    You are not able to interact with that pop-up or see it in Repl because Xamarin doesn't have access to the Android system UI only the application you are running. If you are testing an Android version before 6.0 make sure you have the correct permissions enabled https://developer.xamarin.com/guides/android/application_fundamentals/permissions/

    If you are running Android 6.0.0 or later you can use this workaround
    https://developer.xamarin.com/guides/testcloud/uitest/quickstarts/android/#Running_Android_6.0_Applications_from_the_IDE

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @DevinGuthrie said:
    You are not able to interact with that pop-up or see it in Repl because Xamarin doesn't have access to the Android system UI only the application you are running. If you are testing an Android version before 6.0 make sure you have the correct permissions enabled https://developer.xamarin.com/guides/android/application_fundamentals/permissions/

    This doesn't mention which permission to set.

    I'm already specifying apk file parameter but it doesn't show.

  • DevinGuthrieDevinGuthrie USMember ✭✭

    This doesn't mention which permission to set.

    It depends on what your app is trying to do. In the screenshot above its asking to record audio, I'd try the Record_Audio permission.

    I'm already specifying apk file parameter but it doesn't show.

    What doesn't show? After making this change, the pop-ups are intentionally no longer shown, all permissions are allowed. If your intention is have the pop-up show and select "Deny", I know of no way to do this.

Sign In or Register to comment.