I recently took on a new role at work in the form of using Codeception to create acceptance tests. As this is a learning experience for me I have been dumping a lot of questions onto Stack Overflow. Thanks for all of your help! But here is my newest dilemma. First of all, I am running a cept test. First, it logs in to a website, runs a bunch of tests, then logs out:
$I->am('user');
$I->amOnPage('/');
$I->wait('2');
$I->amOnPage('?realm=ab-cd');
$I->amGoingTo('Login to website');
$I->fillField('username', 'REMOVED');
$I->fillField('password', 'REMOVED');
$I->click('Sign In');
$I->expect('Signing In');
// Should be on dashboard
$I->wait('5');
$I->see('Dashboard');
$I->see('Messages');
$I->see('Assignments');
$I->see('Reports');
$I->see('Help');
$I->click('Sign Out');
$I->expect('Signed Out');
$I->wait('5');
$I->makeScreenshot('Screenshot');
$I->seeCurrentUrlEquals('/');
The screen shot it takes is as if it never logged out. I have tried both clicking the sign out button, and also using the id(as above) to select the sign out button. The problem here, is that i have multiple tests running and when this does not sign out, it makes my next test fail. Is there a way to force sign out a user doing a cest test? I saw in articles about an issue like this a few years ago, but looks like since has been fixed. I tried all recommendations from those articles. Any thoughts?
The link in question that provides the Sign Out:
<button id="log-out" class="red-btn">Sign Out</button>
UPDATE: After adding the line $I->seeCurrentUrlEquals('/'); An error occurs:
[Facebook\WebDriver\Exception\UnexpectedAlertOpenException] Unexpected modal
dialog (text: Fallback login. Enter password): Fallback login. Enter
password
Why do you go to / after logout?
Shouldn't logout take you there automatically?
Your test is not checking if it logged out successfully.
Expect
method is just a comment.
Use see or seeCurrentUrlEquals to verify success of logging out.