因此,我目前正在尝试使用 Playwright 在 Electron App 上自动上传个人资料照片,但我遇到了“filechooser”事件的问题。
await windowA.click('data-testid');
const [fileChooser] = await Promise.all([
windowA.waitForEvent('filechooser'),
// windowA.locator('text=Edit').click(),
windowA.waitForTimeout(3000),
windowA.locator(selector).click(),
]);
用于上传照片的元素不是输入类型,所以我正在使用
await fileChooser.setFiles(
[filepath],
{ timeout: 1000 }
);
问题是试图让剧作家从弹出的输入对话框中选择图像,它不会选择任何文件。我也一直试图让剧作家在我的夹具文件夹中选择一个图像,该文件夹位于测试的相对路径中,但在这两种情况下都没有成功。
Playwright 显示的错误是
page.waitForEvent: Timeout while waiting for event "filechooser"
waiting for event "filechooser"
有谁知道是什么问题?