【发布时间】:2016-07-22 12:52:42
【问题描述】:
我正在尝试在我的功能上下文中编写一个函数,并在操作中添加一个可选部分。
/**
* Function to scroll into view.
*
* @When /^I scroll "([^"]*)" into view( of type "([^"]*)")?$/g
*/
public function iScrollIntoView($locator, $type = "id") {
// Some logic here.
}
所以我的想法是我可以在我的行为脚本中使用:I scroll "foo" into view 或 I scroll "foo" into view of type "bar"
所以我希望类型部分是可选的,虽然正则表达式在在线正则表达式测试器中似乎可以正常工作,但在我的 behat 脚本中似乎不起作用。
当我将 And I scroll "foo" into view 放入我的 behat 脚本时,它无法识别该函数。我的正则表达式有问题吗?或者这是一个行为问题。
【问题讨论】: