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

Add browserContext.downloadsPath #1496

Merged
merged 10 commits into from
Oct 25, 2024
Merged

Add browserContext.downloadsPath #1496

merged 10 commits into from
Oct 25, 2024

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Oct 21, 2024

What?

Users can set where to download files.

const context = await browser.newContext({
    acceptDownloads: true,
    downloadsPath: '/my/directory',
});

If downloadsPath is unset, we create a temporary directory for each BrowserContext with the k6-browser-artifacts- prefix. Note that we do this for every call to NewBrowserContext.

Why?

  • Finding the downloaded files without downloadPaths can be difficult.
  • Allow users to download files to a specific directory they want.
  • To create a temporary directory to save the downloaded files.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Updates: #1289

@inancgumus inancgumus added the feature A new feature label Oct 21, 2024
@inancgumus inancgumus self-assigned this Oct 21, 2024
@inancgumus inancgumus force-pushed the add/downloads-path branch 2 times, most recently from 6442a2d to b6ab52c Compare October 21, 2024 15:42
@inancgumus inancgumus marked this pull request as ready for review October 21, 2024 16:00
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

NewBrowserContext will set this field to the download directory.

Then, we can get it from tests.
This represents the directory where we will store artifacts like
downloaded files.
This will be called from NewBrowserContext and the tests.

We use the given path. Otherwise, we're creating a temporary directory
with the artifactsDirectory prefix.
@inancgumus inancgumus merged commit 943c568 into main Oct 25, 2024
21 of 22 checks passed
@inancgumus inancgumus deleted the add/downloads-path branch October 25, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants