Skip to content

Prevent Video being autosaved with generated name when enabled #526

@FalcoSuessgott

Description

@FalcoSuessgott

So I've enabled the RecordVideo option and I can see that indeed a Video gets saved (e.g: 4b8a57e3ebc91b5e9e9f8e8575bb759a.webm):

...
# Option Pattern for Playwright Browser & Page Options
func WithVideo(video playwright.RecordVideo) Option {
	return func(pw *PW) {
		pw.pageOpts.RecordVideo = &video
	}
}
...

# Playwright Factory Method
func NewPW(opts ...Option) (*PW, error) {
	PW := &PW{
		browserOpts: playwright.BrowserTypeLaunchOptions{},
		pageOpts:    playwright.BrowserNewPageOptions{},
	}

	pw, err := playwright.Run()
	if err != nil {
		return nil, fmt.Errorf("could not start playwright: %w", err)
	}

	PW.Playwright = pw

	for _, opt := range opts {
		opt(PW)
	}

	browser, err := pw.Chromium.Launch(PW.browserOpts)
	if err != nil {
		return nil, fmt.Errorf("could not launch browser: %w", err)
	}

	PW.Browser = browser

	page, err := browser.NewPage(PW.pageOpts)
	if err != nil {
		return nil, fmt.Errorf("could not create page: %w", err)
	}

	PW.Page = &page

	return PW, nil
}

But I actually want to avoid that, meaning I want to be able to decide for myself the path and name of the video that is being recorded using page.Video().SaveAs() method.

So can I overwrite the default behaviour and prevent that the video is being autosaved with a generated name or do I have to manually delete that video (how would I obtain the video name in the first place then?)

Is this the expected behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions