问题
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