Open kepta opened 1 year ago
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 eval
ing 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
eval
ing 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
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.
Do you think others might benefit from this as well?
This will benefit folks writing robust apps which provide local first support.