[Feature] Support permissions for chromium File System Access API
I am the author of bangle-io - a library which allows taking note locally thanks to the File System Access API.
Currently Playwright doesn't support accepting permissions (see the screenshot) to view/edit a local file using the following api.
let dirHandle = await window.showDirectoryPicker();
const perms = await dirHandle.requestPermission(opts);

Do you think others might benefit from this as well?
This will benefit folks writing robust apps which provide local first support.
I really need this in playwright!
Likewise, I would benefit from this as well!
I would also love this feature. :pray:
For intrepid future travelers, I bypassed this by evaling a function that returns a list of filenames and base64 encoded bytes from blobs.
In the browser page:
async function blobToBase64(blob) {
return new Promise((resolve, _) => {
let reader = new FileReader();
reader.onloadend = () => resolve(reader.result.split(',')[1]);
reader.readAsDataURL(blob);
});
}
window.getFilesAsB64 = async function () {
// Get a list of filenames and a list of blobs somehow
let files = {};
for (let i = 0; i < blobs.length; i++) {
files[filenames[i]] = await blobToBase64(blobs[i]);
}
return files;
}
In the playwright-python app:
files = await page.evaluate("window.getFilesAsB64()")
for filename in files:
with open("./"+filename, "wb") as binary_file:
binary_file.write(base64.b64decode(files[filename]))
For intrepid future travelers, I bypassed this by
evaling a function that returns a list of filenames and base64 encoded bytes from blobs.
It's not a workaround for this issue, but a workaround for file writing. In fact, we want permission support for FileSystem Access API just because we are using this API and want to test programs relying on this. If we just want to read/write files, we can use workarounds instead.
This would really come in handy for my team as well. Our app relies heavily on the FSA API
I need this too! 🙏
I bet the Microsoft devs behind https://vscode.dev (which uses the Filesystem API) would appreciate it also.
I need this feature
+1 would be awesome if Playwright supported these APIs
also need
how long do you intend to "collect feedback" for..?
how long do you intend to "collect feedback" for..?
Why is it that github.com is filling up with more and more people complaining about how long tickets have been open for? The sense of entitlement is simply embarrassing. I guess we should go back to a world of only paid, proprietary software?
how long do you intend to "collect feedback" for..?
Why is it that github.com is filling up with more and more people complaining about how long tickets have been open for? The sense of entitlement is simply embarrassing. I guess we should go back to a world of only paid, proprietary software?
oh. i'm sorry for not commenting "+1" like everyfuckingone else 🥴
Are there any news if or when this could be supported? I'm also eagerly waiting for playwright to support this.
For those having the issue, I have implemented a workaround on my app. Instead of providing the FileSystemHandle using showDirectoryPicker, I load a zip (with an input type file) of the test folder that I unzip, and I load all the files into the navigator.storage.getDirectory and then I provide this FileSystemHandle to the rest of the code. It works greatly.
like @Amatewasu mentioning, this works as temporary solution if instance of FileSystemFileHandle is needed. (like on my case)
let fsDir: FileSystemDirectoryHandle;
let fsStoreFileHandle: FileSystemFileHandle;
beforeAll(async () => {
fsDir = await navigator.storage.getDirectory();
fsStoreFileHandle = await fsDir.getFileHandle('some.file', {create: true});
});
this is really important. building any kind of complex browser-based editor/tool relies on this API.. please support
It would be very useful to have built-in support (or a recommended way) to mock these APIs. Is this planned?
Thanks