0
我正在使用Codeception測試Yii2中的表單,當我點擊提交按鈕並希望在通過Ajax接收到ok後重定向到另一個url(通過javascript)時。 我用wait(3)
方法給它一些時間做重定向,但是當我用dontSeeInCurrentUrl()
方法檢查url時,我總是在同一頁面上。點擊提交按鈕後,代碼隱藏仍然在同一頁
這是怎麼發生的?
<?php
$newFamily = [
'name' => 'testFamily'
];
$I->amOnPage('/backend/web/index.php/foobar/create');
$I->seeInCurrentUrl('create');
$I->amGoingTo('try to submit without having enter a name');
$I->click('#submitBtn');
$I->expect('not to have changed of location');
$I->seeInCurrentUrl('create');
$I->amGoingTo('check that parent family select is unchecked');
$I->dontSeeCheckboxIsChecked('#isSuperior');
$I->fillField('#familynutriment-name', $newFamily['name']);
$I->click('#submitBtn');
$I->expectTo('be in another location');
$I->wait(3);
$I->dontSeeInCurrentUrl('create');
$I->seeInDatabase('family_nutriment', $newFamily);