尝试上传文件时,在剧作家中获取以下错误:错误:没有这样的文件或目录

发布于 2025-02-09 15:37:11 字数 1016 浏览 2 评论 0原文

在这里输入映像我刚开始使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囚你心 2025-02-16 15:37:11

因此,您是从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 to src/attachments/TDL/relevantfile-sample.pdf. This should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文