Is there a way to record time to complete an action?

Xamarin UITest : I am aware of the ability to screenshot to give the human User a visual on what the screen looks like, but is there any way to record how long an action takes to perform and maybe generate a list or spit it out to console? Like for example, how long it took in milliseconds for an element to load or how long it took after clicking a button for the action to happen?

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @RandomFeature

    Sure, just get a start and end time and then write to the console, e.g.:

    DateTime startTime = DateTime.Now;
    
    // Do what you want to measure the time for
    
    DateTime endTime = DateTime.Now;
    Console.WriteLine($"Duration: {(endTime - startTime).Milliseconds}");
    

    If you want to generate a list, you could just do:

    DateTime startTime;
    DateTime endTime;
    List<TimeSpan> durations = new List<TimeSpan>();
    
    // repeat the next three lines for all the events you need to time
    startTime = DateTime.Now;
    // Do stuff
    endTime = DateTime.Now;
    durations.Add(endTime - startTime);
    
    // Output the list
    for (int i = 0; i < durations.Count; i++) {
        Console.WriteLine($"Duration {i}: {durations[i].Milliseconds}");
    }
    

    The console output should appear in the Application Output when running the test.

  • ethanwjonesethanwjones Member ✭✭

    Maybe you can use session recordings? They let you see the time between each action in a full session breakdown.

    https://www.appsee.com/features/user-recordings

Sign In or Register to comment.