Skip to content

Wait Methods (Surfmeter Selenium for Java)

If you just call the statistics as shown in the Quick Start section above, you will get results immediately as soon as a first computation is done by the Surfmeter Auto SDK library. This usually happens after the first five seconds. If you want to wait a certain time until the video has progressed, you could do this e.g. by using the following wrapper approach:

class MyTest {

    // ...
    public test() {
        // ...

        SurfmeterMonitoredVideo monitoredVideo = surfmeter.getMonitoredVideo(video);
        monitoredVideo.waitForPlaybackToProgressSeconds(30); // this will wait until the video has played at least 30s or ends before

        // ...
        // do further things after that, e.g. fetch statistics
        SurfmeterVideoQualityStatistics statistics = monitoredVideo.fetchQualityStatistics();

        // ...
    }

    // ...
}

Similar you could also wait until the video has ended in total. Note this is only recommended for short clips and especially NOT for live stream which may run e.g. 24/7.

class MyTest {

    // ...
    public test() {
        // ...

        SurfmeterMonitoredVideo monitoredVideo = surfmeter.getMonitoredVideo(video);
        monitoredVideo.waitUntilPlaybackEnded(600); // this will wait until the video ended or the given timeout of e.g. 600s is exceeded

        // ...
        // do further things after that, e.g. fetch statistics
        SurfmeterVideoQualityStatistics statistics = monitoredVideo.fetchQualityStatistics();

        // ...
    }

    // ...
}