xamarinxamarin.iosui-testingunauthorizedaccessexcepti

Xamarin.iOS UITesting - UnauthorizedAccessException


I ve been experimenting with Xamarin UI Testing on iOS for a while now and everything works as expected, except from the screenshots part. When doing app.Screenshot("First"); I get the following error message:

System.Exception : Error while performing Screenshot("First") ----> System.UnauthorizedAccessException : Access to the path "/screenshot-1.png" is denied.

I have searched everywhere on the web, but I could not find a way to overcome this issue. Any help would be greatly appreciated!

P.S: I have also run Xamarin Studio with administrator privileges but again with no luck


Solution

  • That error was first seen when updating to iOS 10.x.

    1. In your iOS app, make sure that the Xamarin.TestCloud.Agent package is updated to 0.20.3 (latest version).

    2. In your UITest project, make sure that Xamarin.UITest package is updated to the latest stable 2.x version (currently 2.0.5, I am using pre-release 2.0.5.1590-dev) and the NUnit package is updated to version 2.6.4 from the default 2.6.3 (but not update to NUnit 3.x)

    3. Enable local screenshot saving via .EnableLocalScreenshots()

      ConfigureApp.iOS.EnableLocalScreenshots().StartApp();

    Note: Assuming you have done this due to the error you are getting....