<?php use tests\codeception\kpi\AcceptanceTester; /* @var $scenario Codeception\Scenario */ $I = new AcceptanceTester($scenario); $I->wantTo('ensure that home page kpis'); $I->amOnPage(Yii::$app->homeUrl); $I->see('My Company'); $I->seeLink('About'); $I->click('About'); $I->see('This is the About page.');
<?php use tests\codeception\kpi\AcceptanceTester; use tests\codeception\kpi\_pages\AboutPage; /* @var $scenario Codeception\Scenario */ $I = new AcceptanceTester($scenario); $I->wantTo('ensure that about kpis'); AboutPage::openBy($I); $I->see('About', 'h1');
<?php use tests\codeception\kpi\AcceptanceTester; use tests\codeception\common\_pages\LoginPage; /* @var $scenario Codeception\Scenario */ $I = new AcceptanceTester($scenario); $I->wantTo('ensure login page kpis'); $loginPage = LoginPage::openBy($I); $I->amGoingTo('submit login form with no data'); $loginPage->login('', ''); $I->expectTo('see validations errors'); $I->see('Username cannot be blank.', '.help-block'); $I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('try to login with wrong credentials'); $I->expectTo('see validations errors'); $loginPage->login('admin', 'wrong'); $I->expectTo('see validations errors'); $I->see('Incorrect username or password.', '.help-block'); $I->amGoingTo('try to login with correct credentials'); $loginPage->login('erau', 'password_0'); $I->expectTo('see that user is logged'); $I->seeLink('Logout (erau)'); $I->dontSeeLink('Login'); $I->dontSeeLink('Signup'); /** Uncomment if using WebDriver * $I->click('Logout (erau)'); * $I->dontSeeLink('Logout (erau)'); * $I->seeLink('Login'); */
<?php use tests\codeception\kpi\AcceptanceTester; use tests\codeception\kpi\_pages\ContactPage; /* @var $scenario Codeception\Scenario */ $I = new AcceptanceTester($scenario); $I->wantTo('ensure that contact kpis'); $contactPage = ContactPage::openBy($I); $I->see('Contact', 'h1'); $I->amGoingTo('submit contact form with no data'); $contactPage->submit([]); if (method_exists($I, 'wait')) { $I->wait(3); // only for selenium } $I->expectTo('see validations errors'); $I->see('Contact', 'h1'); $I->see('Name cannot be blank', '.help-block'); $I->see('Email cannot be blank', '.help-block'); $I->see('Subject cannot be blank', '.help-block'); $I->see('Body cannot be blank', '.help-block'); $I->see('The verification code is incorrect', '.help-block'); $I->amGoingTo('submit contact form with not correct email'); $contactPage->submit(['name' => 'tester', 'email' => 'tester.email', 'subject' => 'test subject', 'body' => 'test content', 'verifyCode' => 'testme']); if (method_exists($I, 'wait')) { $I->wait(3); // only for selenium } $I->expectTo('see that email adress is wrong'); $I->dontSee('Name cannot be blank', '.help-block'); $I->see('Email is not a valid email address.', '.help-block');