Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 在Spectron中选择并上传测试文件_Typescript_Electron_Webdriver Io_Spectron - Fatal编程技术网

Typescript 在Spectron中选择并上传测试文件

Typescript 在Spectron中选择并上传测试文件,typescript,electron,webdriver-io,spectron,Typescript,Electron,Webdriver Io,Spectron,我必须为包含“选择文件”对话框的electron GUI编写测试。我无法访问GUI的实现 我写过 await app.client.chooseFile('//*[@id="import-file"]/form/div/div/div[1]/input', path.join(__dirname, '..','..','..', 'Fahrtzeit.xlsx')) .catch(function (error) { console.log(error); }).getValue('//*[

我必须为包含“选择文件”对话框的electron GUI编写测试。我无法访问GUI的实现

我写过

await app.client.chooseFile('//*[@id="import-file"]/form/div/div/div[1]/input', path.join(__dirname, '..','..','..', 'Fahrtzeit.xlsx'))
.catch(function (error) {
  console.log(error);
}).getValue('//*[@id="import-file"]/form/div/div/div[1]/input').then(function (val) {

  console.log("value is :"+val);
  });
我得到一个控制台输出

value is :
该值为空

我是斯派克伦的新手。我错过什么了吗

更新: choose file元素的DOM是

<div _ngcontent-c9="" class="mat-form-field-flex"><div _ngcontent-c9="" class="mat-form-field-infix"><input _ngcontent-c9="" class="mat-input-element unit-input ng-untouched ng-pristine ng-valid" formcontrolname="fileDisplay" readonly="" type="text" ng-reflect-name="fileDisplay" title="Auftragsdatei auswählen"></div><button _ngcontent-c9="" class="btn btn-link filepicker-btn unit-filepicker"><ui-icon _ngcontent-c9="" class="filepicker-icon" iconname="a_ic_attach_file" _nghost-c5="" ng-reflect-icon-name="a_ic_attach_file" id="import-file-icon"><div _ngcontent-c5="" class="a_ic_attach_file" ng-reflect-ng-class="a_ic_attach_file"></div></ui-icon></button><div _ngcontent-c9="" class="mat-form-field-underline"></div></div>

参考:

只要控制台val并测试它是否有效

参考:


只要控制台val并测试它是否有效。

同样的问题。该值为空。您可以上载输入字段HTML吗?我的意思是,此元素“/*[@id=“import file”]/form/div/div/div[1]/input”文件是否正在上载。无论文件是否已上载,文本是否已上载。我已经添加了DOMYour input tag属性的类型是text而不是file。“选择文件”仅适用于输入类型为“文件”的情况。同样的问题。该值为空。您可以上载输入字段HTML吗?我的意思是,此元素“/*[@id=“import file”]/form/div/div/div[1]/input”文件是否正在上载。无论文件是否已上载,文本是否已上载。我已经添加了DOMYour input tag属性的类型是text而不是file。“选择文件”仅适用于输入类型为“文件”的情况。输入标记类型属性为“文本”。Choosefile仅在输入类型为FileInput标记类型属性为text时应用。Choosefile仅在输入类型为file时应用
it('Should upload a file',async ()=>{

    let toUpload = path.join(__dirname, '..', '..', 'fixtures', 'Fahrtzeit.xlsx')

    await app.client.chooseFile('//*[@id="import-file"]/form/div/div/div[1]/input', toUpload);

    let val =await app.client.getValue('//*[@id="import-file"]/form/div/div/div[1]/input');

// Do asserts and test the **val** 
})