我試圖在測試之前設置cookie,但由於某些原因,他們沒有設置。PHPUnit Selenium 2擴展設置Cookie
這裏是我的示例代碼:
class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://dev.local/');
}
public function testTitle()
{
$session = $this->prepareSession();
$session->cookie()->remove('language_version');
$session->cookie()->add('language_version', 'en')->set();
$this->url('/');
$this->assertEquals('Title in English', $this->title());
}
}
有誰知道怎麼辦呢?任何幫助不勝感激。
刪除不存在的cookie實際上不會引發任何異常。 – Ralphz
但它可能會默默地忽略其餘的代碼。嘗試在刪除Cookie後立即添加日誌或警報,以查看它是否正在運行以下代碼。 – freegnu