Javascript 如何关闭Node.js中的文件对话框?

Javascript 如何关闭Node.js中的文件对话框?,javascript,node.js,puppeteer,Javascript,Node.js,Puppeteer,我通过node.js打开一个文件对话框,如下所示 await page.goto('https://www.example.com', { waitUntil: 'networkidle0' }); let a = await page.$('#file'); a.click(); 其中html代码如下所示 <form action=""> <input type="file" id="file" /> <input type="submit" id="submi

我通过node.js打开一个文件对话框,如下所示

await page.goto('https://www.example.com', { waitUntil: 'networkidle0' });
let a = await page.$('#file');
a.click();
其中html代码如下所示

<form action="">
<input type="file" id="file" />
<input type="submit" id="submit" value="Submit" />
</form>

无法打开对话框来选择文件。相反,您必须使用来处理文件上载:

let a=wait page.$(“#文件”);
等待.uploadFile('PATH/TO/YOUR.FILE');
让b=等待页面。$('提交');
b、 单击();
let a = await page.$('#file');
a.click();
// HERE close the opened dialog box
let b = await page.$('#submit');
b.click();