首页 > 解决方案 > 自动文件上传

问题描述

我尝试将文件自动上传到正在处理的项目,但文件名在字段中显示为已上传,但实际上并不是因为提交按钮仍然被禁用,但是当我手动上传时,上传按钮将是可点击的。

describe('Upload Test', function () {
  it('Upload Test', function () {
    cy.visit('http://localhost:4200')
    cy.get('#version-no').type('4')
    cy.get('#version-notes').type('test notes ')
    const test_upload = "../fixtures/example.csv";
    cy.get('#file')
      .attachFile(test_upload)


    cy.get('#file')
      .its('0.files')
      .its('0')
      .its('name')
      .should('eq', 'example.csv')

    cy.get('#file')
      .trigger('change', { force: true })

    cy.get('#file')
      .trigger('fileuploadsubmit', { force: true })

    cy.get('[data-cy=Submit_Catalogue]').click({ force: true },'center')
  })
})

这是 HTML

标签: javascripttestingautomated-testscypresscypress-file-upload

解决方案


推荐阅读