0

使用带有 Gherkin 5.1.0 法语测试的 codeceptJs 2.1.1 我试图检查所有字段是否存在于使用数据表提供字段名称的表单中。

这是小黄瓜测试:

@tabletest
Scénario: Les champs
Alors je vois les champs :
| coteComplete   |
| typeOptionCote |

这是相应的步骤:

Then('je vois les champs( de saisie) :', (name) => {
  I.say('name', name);
  I.seeElement(`input[name=${name}], select[name=${name}], textearea[name=${name}]`);
});

这是堆栈跟踪:

$ npx codeceptjs run --grep "tabletest" --debug --verbose
CodeceptJS v2.1.1
Using test root "C:\PISTARD\diffusion\dev\pistard-diffusion"
Helpers: Protractor
Plugins: screenshotOnFail, wdio

Recherche par cote @PDIFF-56 --
    Emitted | suite.before ([object Object])
 » Started SeleniumStandaloneLauncher
 » [Session] Starting singleton browser session
  Les champs @tabletest
    Emitted | test.before ([object Object])
    Emitted | hook.start ([object Object])
    Emitted | step.before (I am on page "recherche-avancee")
    Emitted | step.after (I am on page "recherche-avancee")
    Emitted | step.start (I am on page "recherche-avancee")
    Etant donné que je suis sur la page "recherche avancee"
      I am on page "recherche-avancee"
      » Visited http://localhost:4200/recherche-avancee
    Emitted | step.passed (I am on page "recherche-avancee")
    Emitted | step.finish (I am on page "recherche-avancee")
    Emitted | hook.passed ([object Object])
    Emitted | test.start ([object Object])
    [1] Error | TypeError: Cannot read property 'bold' of undefined
    [1] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [1] <teardown> Stopping recording promises
 » <screenshotOnFail> Test failed, saving screenshot
 » Screenshot has been saved to C:\PISTARD\diffusion\dev\pistard-diffusion\codeceptjs-output\Les_champs_1557763592.failed.png
  × FAILED in 287ms

    [2] Starting recording promises
    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

-- FAILURES:

  1) Recherche par cote @PDIFF-56
       Les champs @tabletest:
     Cannot read property 'bold' of undefined
  ypeError: Cannot read property 'bold' of undefined
      at Object.say (node_modules\codeceptjs\lib\output.js:139:53)
      at recorder.add (node_modules\codeceptjs\lib\actor.js:40:78)
      at process.internalTickCallback (internal/process/next_tick.js:77:7)


  FAIL  | 0 passed, 1 failed   // 5s
    Emitted | global.result ([object Object])
    Emitted | global.after ([object Object])
 » Stopped SeleniumStandaloneLauncher
4

1 回答 1

0

使用节点检查器,我能够在跟踪中进一步看到。将参数添加--node-arg=--inspect-brk到 tyou 命令

npx --node-arg=--inspect-brk codeceptjs run --grep "tabletest" --debug 

然后通过单击节点图标从您的 chrome devtools 中打开 nodejsinspector:

在此处输入图像描述

至于“未定义的粗体”错误它

I.say("InputName:" + name);

关于接收到的变量,我可以看到测试实际上接收到一个包含值数组而不是实际值的对象。可以像这样访问实际值:

let name = dataTest.rows[0].cells[0].value

因此您必须在收到的数组中手动​​循环以获取每个值并对其进行测试

Then('je vois les champs( de saisie)( :)', (dataTest) => {
  let name;
  dataTest.rows.forEach(element => {
    name = element.cells[0].value;
    I.seeElement(`input[name=${name}], select[name=${name}], textearea[name=${name}]`);
  });
  debugger;
});
于 2019-05-13T16:06:53.470 回答