尝试上传文件时,在剧作家中获取以下错误:错误:没有这样的文件或目录
在这里输入映像我刚开始使用playwright(使用typewright(使用TypeRight),所以我对它。我有一个测试脚本,需要上传一个文件。元素类型是非输入HTML,因此我选择上传的FileChooser函数。我已经放置了需要在附件子文件夹部分下载的PDF文件。在此处也附加图像,并连接代码段。根据屏幕截图,我正在更改正在测试文件夹的Watertdlapp.spec.ts。测试和附件文件夹在SRC文件夹下。
完整错误:错误:eNOENT:没有这样的文件或目录,stat'c:\ attactments \ tdl \ siessantfile-sample.pdf'
const filepath = '../../attachments/TDL/relevantfile-sample.pdf';
const [fileChooser] = await Promise.all([
// It is important to call waitForEvent before click to set up waiting.
page.waitForEvent('filechooser'),
// Opens the file chooser.
page.locator("(//*[@class='ant-upload-drag-container'])[1]").click(),
]);
await fileChooser.setFiles(filepath)
有人可以在这里帮我吗?让我知道是否需要其他细节。在此处输入图像描述
enter image description hereI just started using playwright(using typescript), so I am very new to it. I am having a test script where I need to upload a single file. The element type is non-input HTML so I am choosing Filechooser function for the upload. I have placed the pdf file which needs to be uploaded under the attachments subfolder section. Attaching the image here as well and attaching the code snippet too. As per the screenshot, I am making changes to the WaterTDLApp.Spec.ts which is under tests folder. Tests and attachments folders are under src folder.
Full Error : Error: ENOENT: no such file or directory, stat 'C:\attachments\TDL\relevantfile-sample.pdf'
const filepath = '../../attachments/TDL/relevantfile-sample.pdf';
const [fileChooser] = await Promise.all([
// It is important to call waitForEvent before click to set up waiting.
page.waitForEvent('filechooser'),
// Opens the file chooser.
page.locator("(//*[@class='ant-upload-drag-container'])[1]").click(),
]);
await fileChooser.setFiles(filepath)
Could anyone please help me here. Let me know if any other details are needed.enter image description here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,您是从
c:\ oneStop 2.0 Automation \ e2e
中运行测试,然后您必须将文件路径更改为src/actactments/tdl/tdl/siess severantfile-sample.pdf
。这应该起作用。So you are running the tests from
C:\OneStop 2.0 Automation\E2E
, then you have to change the file path tosrc/attachments/TDL/relevantfile-sample.pdf
. This should work.