I have a dropdown for submit form, now issue is when I run test, it gives error:
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.
Here is Dropdown buttons:
<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');
}
}
How I can perform click on dropdown links?
Yii2 module does not support javascript, so clicking on <a href="#">
is rather pointless.
But if you insist, you can click it with $I->click("#schedule_pending")
or
$I->click('SAVE & PENDING')