Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Videos are not complete when an exception is thrown #432

Closed
chaganiu opened this issue May 7, 2021 · 2 comments
Closed

[Bug] Videos are not complete when an exception is thrown #432

chaganiu opened this issue May 7, 2021 · 2 comments

Comments

@chaganiu
Copy link

chaganiu commented May 7, 2021

I have a script like the following:

try {
    playwright = Playwright.create();
    var launchOptions = new BrowserType.LaunchOptions();
    launchOptions
            .setHeadless(false)
            .setSlowMo(300);
    browser = playwright.chromium().launch(launchOptions);
    var videoPath = Paths.get("videos/");

    var contextOptions = new Browser.NewContextOptions()
            .setViewportSize(1920, 1080)
            .setRecordVideoDir(videoPath)
            .setRecordVideoSize(1920,1080);

    context = browser.newContext(contextOptions);
    page = context.newPage();
    page.setDefaultTimeout(60000);

    // do stuff in the web that eventually causes an exception (`Frame.waitForSelector failed` for example)
} catch (Exception e) {
    e.printStackTrace();
} finally {
    page.close();
    context.close();
    browser.close();
    playwright.close();
}

The video is recorded and saved just fine but when i compare where the script failed and the recorded video, the video is missing the end of the script before it failed.

@yury-s yury-s changed the title Videos are not complete when an exception is thrown [Bug] Videos are not complete when an exception is thrown May 19, 2021
@yury-s
Copy link
Member

yury-s commented May 19, 2021

I can reproduce it. The problem happens when the page is explicitly closed, in that case context.close() will not wait for the video to finish recording for that page. I'll prepare a fix.

@yury-s
Copy link
Member

yury-s commented May 19, 2021

The fix is now available in 1.12.0-SNAPSHOT and will be released with 1.11.1 too.

@yury-s yury-s closed this as completed May 19, 2021
aslushnikov pushed a commit to aslushnikov/playwright that referenced this issue May 20, 2021
aslushnikov added a commit to microsoft/playwright that referenced this issue May 20, 2021
- Cherry-Pick PR #6648 SHA b946437
- Cherry-Pick PR #6664 SHA 2ef47b9

References microsoft/playwright-java#432

Co-authored-by: Yury Semikhatsky <yurys@chromium.org>
This was referenced May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants