我正在尝试使用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的情况下重启貂皮?
这很好用!谢谢 :) –