0
我想在我的功能上下文中使用動作中的可選部分編寫函數。Behat featurecontext可重複使用的動作正則表達式問題
/**
* 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"
所以我想要的類型部分是可選的,而正則表達式似乎在網上正則表達式測試儀做工精細,它似乎並不適用於我的腳本。
當我把And I scroll "foo" into view
放在我的behat腳本中時,它不能識別這個函數。我的正則表達式有什麼問題嗎?或者這是一個問題。