Naz*_*ain -1 cypress cypress-file-upload
首先单击并从下拉列表中选择如何上传计算机或驱动器等文件,选择计算机后我必须从赛普拉斯的计算机上传。我正在尝试这种方式,但不起作用,点击后无任何操作
cy.get(this.business_registration).click()
cy.fixture('images.png').then(fileContent => {
cy.get(this.select_browse).attachFile({
fileContent,
fileName: 'images.png',
mimeType: 'image/png'
});
});
Run Code Online (Sandbox Code Playgroud)
Cypress 的做法是什么?
看来您忽略了上一个问题的答案中的建议。
您尚未使用.then(Cypress.Blob.base64StringToBlob)@ryry 给出的 Blob 转换以及 Cypress 自己在此处提供的Blob 转换Image Fixture
// programmatically upload the logo
cy.fixture('images/logo.png').as('logo')
cy.get('input[type=file]').then(function ($input) {
// convert the logo base64 string to a blob
const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
// pass the blob to the fileupload jQuery plugin
// https://github.com/blueimp/jQuery-File-Upload
// used in your application's code
// which initiates a programmatic upload
$input.fileupload('add', { files: blob })
})
Run Code Online (Sandbox Code Playgroud)
另外,您提到的似乎.click()并没有改变问题的基础。
| 归档时间: |
|
| 查看次数: |
76 次 |
| 最近记录: |