E2E - 输入文件。如何在加载和选择文件后关闭 Finder Window?
E2E - Input file. How to close Finder Window after loading and selecting file?
我使用输入文件从 xml 文件加载数据。
HTML代码:
<button (click)="xmlFile.click()" id="btnLoadXmlFile">
Load data from file
</button>
<input type="file" (change)="handleFileInput($event)" accept="text/xml" class="load-xml-file" id="inputLoadXML" #xmlFile>
<span>{{ chosenFile }}</span>
E2E代码:
it( "Should load data from XML file", () => {
const path = require('path');
const fileToUpload = '../../src/assets/xml/myXmlFile.xml',
absolutePath = path.resolve(__dirname, fileToUpload);
componentPo.getDomElements().btnLoadXML.click();
componentPo.getDomElements().inputLoadXML.sendKeys(absolutePath);
});
除了在选择文件和加载数据后无法关闭取景器 window(Mac 用户)外,它工作正常。也会导致端到端失败
任何提示或想法如何解决这个问题并强制 Finder window 在选择文件后关闭?
无需单击 File Upload
按钮即可上传文件。 sendKeys
会为您做到这一点。请从现有代码中删除 componentPo.getDomElements().btnLoadXML.click();
。
it( "Should load data from XML file", () => {
const path = require('path');
const fileToUpload = '../../src/assets/xml/myXmlFile.xml',
absolutePath = path.resolve(__dirname, fileToUpload);
componentPo.getDomElements().inputLoadXML.sendKeys(absolutePath);
});
我使用输入文件从 xml 文件加载数据。
HTML代码:
<button (click)="xmlFile.click()" id="btnLoadXmlFile">
Load data from file
</button>
<input type="file" (change)="handleFileInput($event)" accept="text/xml" class="load-xml-file" id="inputLoadXML" #xmlFile>
<span>{{ chosenFile }}</span>
E2E代码:
it( "Should load data from XML file", () => {
const path = require('path');
const fileToUpload = '../../src/assets/xml/myXmlFile.xml',
absolutePath = path.resolve(__dirname, fileToUpload);
componentPo.getDomElements().btnLoadXML.click();
componentPo.getDomElements().inputLoadXML.sendKeys(absolutePath);
});
除了在选择文件和加载数据后无法关闭取景器 window(Mac 用户)外,它工作正常。也会导致端到端失败
任何提示或想法如何解决这个问题并强制 Finder window 在选择文件后关闭?
无需单击 File Upload
按钮即可上传文件。 sendKeys
会为您做到这一点。请从现有代码中删除 componentPo.getDomElements().btnLoadXML.click();
。
it( "Should load data from XML file", () => {
const path = require('path');
const fileToUpload = '../../src/assets/xml/myXmlFile.xml',
absolutePath = path.resolve(__dirname, fileToUpload);
componentPo.getDomElements().inputLoadXML.sendKeys(absolutePath);
});