Cypress学习文档

沉淀cypress对常用html组件定位的文档


文件上传操作(使用)

<h1>1. cypress中使用</h1> <h2>1.1 上传普通文本文件</h2> <pre><code class="language-javascript"> //choose local chart file cy.get('#chart-upload_chartFile').attachFile('&lt;path&gt;/&lt;under&gt;/&lt;fixture&gt;/file.json');</code></pre> <h2>1.2 上传二进制文件</h2> <p>指定文件为binary,</p> <pre><code class="language-javascript"> const fileName = '&lt;path&gt;/&lt;under&gt;/&lt;fixture&gt;/file.tar.gz' cy.fixture(fileName, 'binary') .then(Cypress.Blob.binaryStringToBlob) .then(fileContent =&gt; { cy.get('#chart-upload_chartFile').attachFile({ fileContent, fileName, mimeType: 'application/x-gzip', encoding:'utf8' }) })</code></pre> <h1>2. Reference</h1> <p>[1]. <a href="https://npm.devtool.tech/cypress-file-upload">cypress file upload npm</a> [2]. <a href="https://github.com/abramenal/cypress-file-upload/tree/edb15cb25bae83319ee646f2d0e32bf8e8e3d4da#working-with-raw-file-contents">cypress file upload github link</a></p>

页面列表

ITEM_HTML