Yii2 Codeception测试点击下拉菜单

Yii2 Codeception test click on a dropdown menu

我有一个用于提交表单的下拉菜单,现在问题是当我 运行 测试时,它给出了错误:

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>

Class 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');
    }
}

如何点击下拉链接?

Yii2模块不支持javascript,所以点击<a href="#">是没有意义的。

但是如果你坚持的话,你可以用$I->click("#schedule_pending")点击它或者 $I->click('SAVE & PENDING')