1
我有一個下拉的提交表單上Yii2 Codeception測試一下,現在的問題是,當我運行測試,它提供了錯誤:下拉菜單
1) Failed to ensure that clients create works in tests\codeception\frontend\acceptance\ClientCrudCest::testClientCreate (.\acceptance\ClientCrudCest.php)
Step I click "schedule_pending"
Fail Link or Button by name or CSS or XPath element with 'schedule_pending' was not found.
Scenario Steps:
13. $I->click("schedule_pending") at _pages\ClientCrudPage.php:26
12. // I am going to submit client form with no data
11. $I->see("Client Profile") at acceptance\ClientCrudCest.php:63
10. $I->see("Add Client","h3") at acceptance\ClientCrudCest.php:62
9. $I->amOnPage("/frontend/web/index-test.php/clients/create") at tion\BasePage.php:77
8. $I->dontSeeLink("Sign In") at acceptance\ClientCrudCest.php:56
FAILURES!
Tests: 1, Assertions: 4, Failures: 1.
這裏是下拉按鈕:
<ul class="dropdown-menu" role="menu">
<li><a href="#" id="schedule_pending" class="enroll-client-btn">SAVE & PENDING</a></li>
<li><a href="#" id="schedule_enrollment" class="enroll-client-btn">SAVE & ENROLLMENT</a></li>
<li><a href="#" id="schedule_appointment" class="enroll-client-btn">SAVE & APPOINTMENT</a></li>
<li><a href="#" id="schedule_eval" class="enroll-client-btn">SAVE & EVALUATION</a></li>
</ul>
類ClientCrudPage:
class ClientCrudPage extends BasePage
{
public $route = 'clients/create';
public function submit(array $signupData)
{
foreach ($signupData as $field => $value) {
$inputType = $field === 'body' ? 'textarea' : 'input';
$this->actor->fillField($inputType . '[name="Clients[' . $field . ']"]', $value);
}
$this->actor->click('schedule_pending');
}
}
如何執行點擊下拉鍊接?
請單擊它看到這個http://www.yiiframework.com/forum/index.php/topic/71289-how-i-can- use-i-in-clientcrudpage-extend-basepage/ –
查看http://codeception.com/docs/06-ReusingTestCode#PageObjects中的登錄方法 – Naktibalda