I have test class defined as this-
public class Sample extends BaseTest {
private LoginPage loginPage;
@Override
public void initialize() {
loginPage = createInstance(LoginPage.class)
browserContext = getBrowserContext();
}
@Test(testName = "sampleTestName", retryAnalyzer = RerunFailedTestCases.class)
public void sampleTestName() {
loginPage.performLogin();
loginPage.validateLogInSuccessful();
}
In BaseTest I am initializing BrowserContext and enabling video recording for the tests-
public abstract class BaseTest {
protected BrowserContext browserContext = browser.newContext(new Browser.NewContextOptions()
.setIgnoreHTTPSErrors(true)
.setPermissions(Arrays.asList("geolocation"))
.setRecordVideoDir(Paths.get(VIDEOS_DIR)));
}
My requirement is-
After the page is closed, you can using page.video().saveAs() to save the video to a custom path.
BrowserContext context = browser
.newContext(new Browser.NewContextOptions()
.setRecordVideoDir(Paths.get("videos/")));
Page page = context.newPage();
page.close(); // Make sure the page is closed before calling page.video()
page.video().saveAs(Paths.get("abc.webm"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With