Grey Dog Blog
Thoughts, musings, tips & tricks

videoview

Do you have videos in your app? Would you like to test the workflow surrounding your video using Xamarin UITest? Don't want to slow down your UI tests waiting for the video to play? Then just fastforward through the video play:

public class VerifyVideoCommand
{
    readonly IApp _app;
    readonly IWelcomeScreen _welcomeScreen;
    public VerifyVideoCommand ()
    {
        _app = FeatureContext.Current.Get<IApp>("App");
        _welcomeScreen = FeatureContext.Current.Get<IWelcomeScreen>(ScreenNames.WelcomeScreen);
    }
    public void Execute ()
    {
        //Tap the videoView to show the seekbar
        _app.WaitForElement(_welcomeScreen.VideoView, timeout: TimeConstants.TwentySeconds);
        _app.Tap(_welcomeScreen.VideoView);
        //Move the seekbar
        _app.Tap(_welcomeScreen.VideoView);
        _app.WaitForElement(_welcomeScreen.VideoSeekBar, timeout: TimeConstants.TwentySeconds);
        var slider = _app.Query(_welcomeScreen.VideoSeekBar).First();
        _app.TapCoordinates(slider.Rect.Width, slider.Rect.CenterY);
    }
}