public static function openBy($I, $params = [], $user = []) { $page = new static($I); // force sign out self::signout($I); if ($user) { $signinPage = SigninPage::openBy($I); $signinPage->signin($user['email'], $user['password']); } $I->amOnPage($page->getUrl($params)); return $page; }
<?php use tests\_pages\SigninPage; $I = new TestGuy($scenario); $I->wantTo('ensure that signin works correctly'); $signinPage = SigninPage::openBy($I); $I->amGoingTo('sign in with empty credentials'); $signinPage->signin('', ''); $I->expectTo('see validations errors'); $I->see('Email cannot be blank.'); $I->see('Password cannot be blank.'); $I->amGoingTo('sign in with wrong credentials'); $signinPage->signin('*****@*****.**', 'secure'); $I->expectTo('see error message'); $I->see('Incorrect username or password.'); $I->amGoingTo('sign in with correct credentials'); $signinPage->signin('*****@*****.**', '123123'); $I->expectTo('see all notes title'); $I->see('All notes');