Acceptance Test with URL Redirection

0

Hello, I'm trying to generate a acceptance test for my login page using codeception and Yii2 , but the problem is that after login the user is redirected to the main page and there the user, already logged in, displays a welcome message. I have tried in many ways but I have not been able to continue. Can someone help me! Thank you.

use \AcceptanceTester;

class LoginCest
{
    public function login(AcceptanceTester $I)
    {
        $I->am('Login Page');
        $I->wantTo('Login Exists?');
        $I->amOnPage('/index.php?r=site/login');
        $I->see('Title');
        $I->see('User');
        $I->see('Password');
    }

    /**
    * @after login
    */
    public function validLogin(AcceptanceTester $I)
    {
        $I->amOnPage('/index.php?r=site/login');
        $I->fillField('LoginForm[username]', 'username');
        $I->fillField('LoginForm[password]', 'password');
        $I->click('Login');
        $I->amOnPage('/index.php');
        $I->see('Welcome {UserName}!', 'h1');
    }
}

Scenario Steps:
6. I see "Welcome!","h1" <<< FAIL
5. I am on page "/index.php"
4. I click "Login"
3. I fill field "LoginForm[password]","username"
2. I fill field "LoginForm[username]","password"
1. I am on page "/index.php?r=site/login"

FAILURES! Tests: 2, Assertions: 4, Failures: 1.
    
asked by anonymous 08.06.2015 / 20:21

0 answers