我正在尝试使用Cucumber.JS进行自动化测试。如果我这样做......
var sharedSteps = module.exports = function(){
this.World = require("../support/world.js").World;
this.When(/^I click on the cart$/, function(next) {
this.client.click("#cartLink", function(err, res){
});
});
...
}
Scenario: Make sure clicking on the cart works
Given I go on the website "https://site.com/"
When I click on the cart
Then I should be on the cart page
但是,如果我使用和
执行以下操作,则一切正常var sharedSteps = module.exports = function(){
this.World = require("../support/world.js").World;
this.And(/^I click on the cart$/, function(next) {
this.client.click("#cartLink", function(err, res){
});
});
...
}
Scenario: Make sure clicking on the cart works
Given I go on the website "https://site.com/"
And I click on the cart
Then I should be on the cart page
我得到了
TypeError:Object#没有方法'And'
那么这样做的正确方法是什么(不用说你应该在什么时候使用,因为我还有其他不那么简单的场景)
答案 0 :(得分:3)
我最终能够在小黄瓜中使用And并使用this.When