问题描述
我正在尝试使用setFilesToUpload()
方法通过testcafe将文档上传到DropBox。
我已经尝试了一些方法,但是没有任何运气:
- 对输入定位符的可见性进行了尝试
- 试图寻找各种定位器,但可以接受输入
有人遇到类似的问题吗?有人可以帮忙吗?
谢谢
解决方法
您的测试代码看起来正确。可能不清楚该文件实际上是上载的。要确认这一点,您可以检查输入元素的value
属性。这是一个示例测试:
import { Selector } from 'testcafe';
fixture `fileUpload`.page `./index.html`;
test('fileUpload',async t => {
const input = Selector('input[type="file"]',{ visibilityCheck: false });
await t.setFilesToUpload(input,['./img.jpg'])
.expect(input.value).eql('C:\\fakepath\\img.jpg');
})
有一种在the TestCafe website上上传文件的方法。