我正在嘗試使用Behat/Mink測試「記住我」功能。這裏是我的情況:如何重新啓動瀏覽器在Behat中保存cookie?
Scenario: A user logs in ticking "Remember me". As he closes his browser and visits back the site, he should be automatically logged in
Given I am on "/login"
Then I should see "Site Login"
When I fill in "Username" with "test"
And I fill in "Password" with "test"
And I check "Remember me"
When I press "Login"
Then I should see "Welcome"
When I restart the browser
Then I go to "/login"
Then I should see "Welcome"
下面是重新啓動瀏覽器的定義:
/**
* @When /^I restart the browser$/
*/
public function iRestartTheBrowser()
{
$this->getSession()->restart();
}
我也曾嘗試$this->getSession()->reset();
問題是因爲Cookie是在瀏覽器重啓刪除,「記得我「功能不再有效。有沒有辦法在不清除cookie的情況下重啓貂皮?
這很好用!謝謝 :) –