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

Disable screenshot file creation when getting base64 #6637

Open
4 tasks done
unional opened this issue Oct 3, 2024 · 3 comments
Open
4 tasks done

Disable screenshot file creation when getting base64 #6637

unional opened this issue Oct 3, 2024 · 3 comments
Labels
p2-to-be-discussed Enhancement under consideration (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
@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-to-be-discussed Enhancement under consideration (priority)
Projects
Status: P2 - 2
Development

No branches or pull requests

2 participants