Skip to content

Disable screenshot file creation when getting base64 #6637

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

Open
4 tasks done
unional opened this issue Oct 3, 2024 · 3 comments · May be fixed by #7777
Open
4 tasks done

Disable screenshot file creation when getting base64 #6637

unional opened this issue Oct 3, 2024 · 3 comments · May be fixed by #7777
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@unional
Copy link

unional commented Oct 3, 2024

Clear and concise description of the problem

Currently, when page.screenshot({ base64: true }), the file is still being created.

I want to delegate the file creation to another code similar to jest-image-snapshot.

https://vitest.dev/guide/browser/locators.html#screenshot

Suggested solution

IMO when doing { base64: true } it should not generate the file. It should even return Promise<Buffer> like how it is done in playwright.

If we want to avoid breaking change, we can add { skipFileCreation?: true } option.

Alternative

playwright does not create the file by default:

  /**
   * The file path to save the image to. The screenshot type will be inferred from file extension. If `path` is a
   * relative path, then it is resolved relative to the current working directory. If no path is provided, the image
   * won't be saved to the disk.
   */
  path?: string;

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

IMO when doing { base64: true } it should not generate the file. It should even return Promise<Buffer> like how it is done in playwright.

There is no such thing as Buffer in the browser.

Currently, when page.screenshot({ base64: true }), the file is still being created

The API is universal - currently, webdriverio always creates a file. This is the main reason why it's the same across the board. I guess, technically we can have different behaviours between different providers.

@sheremet-va sheremet-va self-assigned this Oct 7, 2024
@sheremet-va sheremet-va added p2-to-be-discussed Enhancement under consideration (priority) and removed enhancement: pending triage labels Oct 7, 2024
@sheremet-va sheremet-va removed their assignment Oct 7, 2024
@sheremet-va sheremet-va moved this to P2 - 2 in Team Board Oct 7, 2024
@unional
Copy link
Author

unional commented Oct 9, 2024

currently, webdriverio always creates a file

Can webdriverio disable the file creation? playwright default is not creating a file. IMO that is a better approach/default as the behavior is more decoupled.

Currently, per documentation the path must be a relative path, which further limits the ability to fake it by saving it to a vinyl or temp folder.

@sheremet-va
Copy link
Member

sheremet-va commented Oct 14, 2024

Can webdriverio disable the file creation?

You are quoting the answer to your own question. It cannot. (At least, to my knowledge)

@sheremet-va sheremet-va moved this from P2 - 2 to Approved in Team Board Nov 21, 2024
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed p2-to-be-discussed Enhancement under consideration (priority) labels Mar 28, 2025
@sheremet-va sheremet-va linked a pull request Apr 1, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Status: Approved
Development

Successfully merging a pull request may close this issue.

2 participants