Xamarin.UITest System.Xml.XmlException

444 views Asked by At

I am creating a UI test for my Xamarin.Forms app. When I try to start the first test for iOS project, I get a System.Xml.XmlException (detailed below). This basic test should be working, right?

Update: If I uninstall the app from the simulator, the test runs for the first time. After that I keep getting the exception for all following runs.

I am using Xamarin Studio (6.1.3 build 19) and Xamarin.UITest package (2.0.5)

namespace UITest
{
    [TestFixture (Platform.Android)]
    [TestFixture (Platform.iOS)]
    public class Tests
    {
        IApp app;
        Platform platform;

        public Tests (Platform platform)
        {
            this.platform = platform;
        }

        [SetUp]
        public void BeforeEachTest ()
        {
            app = AppInitializer.StartApp (platform);
        }

        [Test]
        public void AppLaunches ()
        {
            try {
                app.WaitForElement ("Waiting for fake element", "Timeout", new TimeSpan (0, 0, 20));
            } catch (TimeoutException ex) {
                int i = 5;
            }

            app.Screenshot ("Welcome screen.");
            app.Tap ("TestButton");
            app.Screenshot ("New test screen.");
        }
    }

    public class AppInitializer
    {
        public static IApp StartApp (Platform platform)
        {

            if (platform == Platform.Android) {
                return ConfigureApp
                    .Android

                    .StartApp ();
            }

            return ConfigureApp
                .iOS

                .Debug ()
                .EnableLocalScreenshots ()
                .StartApp ();
        }
    }
}

Exception details:

SetUp : System.Xml.XmlException : '', hexadecimal value 0x01, is an invalid character. Line 11, position 11.
    Stack trace:
      at Xamarin.UITest.iOS.iOSAppLauncher.LaunchAppLocal (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, System.Boolean clearAppData) [0x0020a] in <e747267e258a4a668973c7ca7e9014a8>:0 
      at Xamarin.UITest.iOS.iOSAppLauncher.LaunchApp (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, Xamarin.UITest.TestCloud.TestCloudiOSAppConfiguration testCloudAppConfiguration, Xamarin.UITest.Shared.Http.HttpClient testCloudWsClient, Xamarin.UITest.Shared.Http.HttpClient xtcServicesClient, System.Boolean testCloudUseDeviceAgent) [0x0007a] in <e747267e258a4a668973c7ca7e9014a8>:0 
      at Xamarin.UITest.iOS.iOSApp..ctor (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration) [0x00302] in <e747267e258a4a668973c7ca7e9014a8>:0 
      at Xamarin.UITest.Configuration.iOSAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in <e747267e258a4a668973c7ca7e9014a8>:0 
      at UITest.AppInitializer.StartApp (Xamarin.UITest.Platform platform) [0x0001f] in /Users/samg/projects/myapp-mobile/myapp-mobile-2/UITest/AppInitializer.cs:38 
      at UITest.Tests.BeforeEachTest () [0x00008] in /Users/samg/projects/myapp-mobile/myapp-mobile-2/UITest/Tests.cs:26 
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:305 
1

There are 1 answers

1
Maurits van Beusekom On

I know this is an old question, however it might help others. I experienced the same problem described above and solved it by resetting the iOS simulator.

One way to accomplish this is to take the following steps:

  • Make sure the iPhone/iPad simulator is running;
  • Go to the top-menu and select "iOS Simulator" -> "Reset Content and Settings..."