33 文字
1 分

Playwrightでファイル選択をする

2023-04-08

Playwright は FileChooser オブジェクトを利用すると、ファイル選択をエミュレートできる。

https://playwright.dev/docs/api/class-filechooser

const fileChooserPromise = page.waitForEvent("filechooser");
await page.getByText("Upload file").click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, "myfile.pdf"));
Playwrightでファイル選択をする
https://blog.ohirunewani.com/posts/playwright-filechooser/
作者
hrdtbs
公開日
2023-04-08
ライセンス
CC BY-NC-SA 4.0