xamarin.uitest - test finished with message "Length cannot be less than zero."

maurjiumaurjiu Member
edited February 13 in General

Version Visual Studio for Mac 8.4.5
Version xamarin.uitest: 3.0.6

When i use helper class:

public class InitApp
    {
        public static iOSApp connectApp()
        {
            return ConfigureApp.iOS
                .InstalledApp(Params.bundleId)
                .EnableLocalScreenshots()
                .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
        }

        public static iOSApp startApp()
        {
            return ConfigureApp.iOS
                .InstalledApp(Params.bundleId)
                .EnableLocalScreenshots()
                .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
        }
    }

Test finishes execution with message: "Length cannot be less than zero." (reproduced for android tests), if in the test code repeatedly call one of the methods of the InitApp class. Example:

app = InitApp.startApp(); //succeeds
app = InitApp.connectApp(); //the test ends with a message "Length cannot be less than zero."

OR

app = InitApp.startApp(); //succeeds
app = InitApp.startApp(); //the test ends with a message "Length cannot be less than zero."

In version 3.0.5 does not reproduced

Tagged:

Posts

  • JohnHJohnH GBMember ✭✭✭✭✭

    The code for startApp and connectApp is the same, so it looks like you are trying to .StartApp twice. Maybe that is the issue?

  • maurjiumaurjiu Member
    edited February 14

    Don't think. I made a mistake in the example of the InitApp class.

    public class InitApp
        {
            public static iOSApp connectApp()
            {
                return ConfigureApp.iOS
                    .InstalledApp(Params.bundleId)
                    .EnableLocalScreenshots()
                    .ConnectToApp();
            }
    
            public static iOSApp startApp()
            {
                return ConfigureApp.iOS
                    .InstalledApp(Params.bundleId)
                    .EnableLocalScreenshots()
                    .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
            }
        }
    

    Before a TestSuite I do:

    [OneTimeSetUp]
    public void Init() {
        app = InitApp.startApp();
    }
    

    Before each test I do:

    [SetUp]
    public void Setup() {
        try {
            app = InitApp.connectApp(); //the test ends with a message "Length cannot be less than zero."
        } catch {
            app = InitApp.startApp();
        }
    }
    
Sign In or Register to comment.