each key must be a number of string; got function

拥有回忆 提交于 2019-12-11 17:53:11

问题


I have this scenario in Cucumber:

Scenario Outline: Protractor and Cucumber Test InValid

    Given I have already......
    When I fill the <number>
    ....


    Examples:
| number|...
| 3 |...
|4  |...

And I have this stepdefinition in a .js file:

 When('I fill the {int}',{timeout: 90 * 1000},  function(callback, number) {

        element(by.css("*[id='field_identificador']")).click();
        element(by.css("*[id='field_identificador']")).sendKeys(number).then(callback);

    });

I am getting this error: each key must be a number of string; got function

When I execute the test by putting a value by myself without scenario outline, for example: .sendKeys('4') it works.

Am I doing something wrong?


回答1:


You have your arguments in the wrong order. callback is always the last element in the arguments list.

fix:

When('I fill the {int}',{timeout: 90 * 1000},  function(number, callback) {

        element(by.css("*[id='field_identificador']")).click();
        element(by.css("*[id='field_identificador']")).sendKeys(number).then(callback);

    });


来源:https://stackoverflow.com/questions/51028287/each-key-must-be-a-number-of-string-got-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!