如何使用赛普拉斯测试文件输入? [英] How to test file inputs with Cypress?

查看:137
本文介绍了如何使用赛普拉斯测试文件输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写需要与文件输入DOM元素交互的e2e流测试?

How can I write an e2e test of flow that requires interaction with the file Input DOM element?

如果是文本输入,我可以与它进行交互(检查值) ,设置值)等作为DOM组件。但是如果我有一个文件输入元素,我猜测交互是有限的,直到我可以打开对话框来选择文件。我不能继续前进并选择我要上传的文件,因为对话框是原生的而不是某些浏览器元素。

If it's a text input I can interact with it (check value, set value) etc as its a DOM component. But If I have a File Input element, I am guessing that the interaction is limited till I can open the dialog to select a File. I can't move forward and select the file I want to upload as the dialog would be native and not some browser element.

那么如何测试用户是否可以从我的网站正确上传文件?我正在使用赛普拉斯来编写我的e2e测试。

So how would I test that a user can correctly upload a file from my site? I am using Cypress to write my e2e tests.

推荐答案

赛普拉斯尚不支持测试文件输入元素。测试文件输入的唯一方法是:

Testing File Input elements is not yet supported in Cypress. The only way to test File Inputs is to:


  1. 发出原生事件(赛普拉斯的路线图)。

  2. 了解您的应用程序如何使用File API处理文件上传,然后将其存根。它可能但不够通用,无法提供任何具体的建议。

有关更多详细信息,请参阅此未解决的问题

这篇关于如何使用赛普拉斯测试文件输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆