如何按<a> link with zombie.js?

时间:2016-05-13 14:37:40

标签: bdd zombie.js cucumberjs

I am using behavior driven development with cucumber-js, and trying to write a test to follow a link, and I have the following code:

When I click "Add page"

this.When(/^I click "([^"]*)"$/, function(link, callback) {
  this.browser.pressButton(link, callback);
});

Add page is a link button:

<a href="/surveys"><button>Add page</button></a>

The idea that the zombie rest on the same page after pressing the button, is there an other way ?

1 个答案:

答案 0 :(得分:2)

函数pressButton用于按下页面上的按钮。 要单击页面上的链接,请使用clickLink功能。

所以你的代码应该是:

this.When(/^I click "([^"]*)"$/, function(link, callback) { this.browser.clickLink(link, callback); });