Skip to content

Commit 9b3f6c1

Browse files
committed
Add beforeRecordingSaveWaitTime
1 parent a932eb9 commit 9b3f6c1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.2.4
2+
* New option ``beforeRecordingSaveWaitTime`` in ``BrowserWebDriverContainer``
3+
* If not ``null``: Waits the amount of specified time before saving the recording
4+
* This way no frames that may show the problem are accidentally lost
5+
* Default value is set to ``70ms`` which is 1 full frame when recording at the default 15 FPS
6+
17
# 1.2.3
28
* Make some constants externally accessible
39
* Provide chromium image (Chrome doesn't work on ARM64)

testcontainers-selenium/src/main/java/software/xdev/testcontainers/selenium/containers/browser/BrowserWebDriverContainer.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ public class BrowserWebDriverContainer<SELF extends BrowserWebDriverContainer<SE
114114
protected Path recordingDirectory;
115115
protected TestRecordingFileNameFactory testRecordingFileNameFactory = new DefaultTestRecordingFileNameFactory();
116116
protected Duration recordingSaveTimeout = Duration.ofMinutes(3);
117+
// Ensure that the current frame will be fully recorded (default record FPS = 15 -> 67ms per Frame)
118+
protected Duration beforeRecordingSaveWaitTime = Duration.ofMillis(70);
117119

118120
public BrowserWebDriverContainer(final String dockerImageName)
119121
{
@@ -211,6 +213,13 @@ public SELF withRecordingSaveTimeout(final Duration recordingSaveTimeout)
211213
this.recordingSaveTimeout = recordingSaveTimeout;
212214
return this.self();
213215
}
216+
217+
public SELF withBeforeRecordingSaveWaitTime(final Duration beforeRecordingSaveWaitTime)
218+
{
219+
this.beforeRecordingSaveWaitTime = beforeRecordingSaveWaitTime;
220+
return this.self();
221+
}
222+
214223
// endregion
215224

216225
// endregion
@@ -453,6 +462,18 @@ protected void retainRecordingIfNeeded(final String testName, final boolean succ
453462
default -> false;
454463
})
455464
{
465+
if(this.beforeRecordingSaveWaitTime != null)
466+
{
467+
try
468+
{
469+
Thread.sleep(this.beforeRecordingSaveWaitTime.toMillis());
470+
}
471+
catch(final InterruptedException e)
472+
{
473+
Thread.currentThread().interrupt();
474+
throw new IllegalStateException("Got interrupted", e);
475+
}
476+
}
456477
try
457478
{
458479
final Path recording = Timeouts.getWithTimeout(

0 commit comments

Comments
 (0)