这是我的密码
我已经安装了柏树文件上传
导入'cypress-file-upload';文件中的代码
describe('TEST', function(){
it('File upload', function(){
cy.visit('https://tinypng.com/')
})
it('File Upload using cypress-file-upload package', () => {
const filepath = 'train.jpg'
cy.get('.icon').attachFile(filepath)
cy.wait(5000)
})
})发布于 2021-07-06 10:56:47
figure.icon元素在tinypng.com上需要一个文件被拖动到它上,但是对于cypress文件上传,拖放选项不是默认的。
这会成功的,
cy.get('.icon')
.attachFile(filepath, { subjectType: 'drag-n-drop' })如果您愿意,页面上有一个输入。
cy.get('input[type="file"]')
.attachFile(filepath, { subjectType: 'input' }) // input is the default type,
// so not strictly neededhttps://stackoverflow.com/questions/68267329
复制相似问题