我正在为我的 Xamarin.Forms 应用程序创建 UI 测试。当我尝试开始 iOS 项目的第一个测试时,我得到了一个System.Xml.XmlException
(详情如下)。这个基本测试应该有效,对吧?
更新:如果我从模拟器中卸载应用程序,测试将首次运行。之后,我不断收到所有后续运行的异常。
我正在使用 Xamarin Studio(6.1.3 build 19)和 Xamarin.UITest 包(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 ();
}
}
}
异常详情:
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