mercredi 1 novembre 2017

How can the codeception get the text from alert in yii2?

I've the problem. I want to get some texts from alert that created by yii2 when the input text was blank. So here is test case on codeception (functional):

public function submitEmptyForm(\FunctionalTester $I)
    {
        $I->submitForm('#contact-form', []);
        $I->expectTo('see validations errors');
        $I->see('Contact', 'h1');
        $I->see('Name cannot be blank');
        $I->see('Email cannot be blank');
        $I->see('Subject cannot be blank');
        $I->see('Body cannot be blank');
        $I->see('The verification code is incorrect');
    }

And I ran that code, but I found the error in line:

$I->see('Name cannot be blank');

When I spec the code with inspect element, Here's the alert that I got:

<p class="help-block help-block-error">Name cannot be blank.</p>

How can I get the alert text when the doesn't have name or id ? I read "How to call element in codeception" in codeception.com, you should be called by name or id.

Aucun commentaire:

Enregistrer un commentaire