I am trying to test a project but unable to check the login page due to this error:
[RuntimeException] Call to undefined method AcceptanceTester::loadSessionSnapshot
This is my code:
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Login');
$I->amOnPage('/');
if($I->loadSessionSnapshot('loggedin')) exit();
$I->dontSee('NotFound');
//$I->dontSee('Error');
$csrf = $I->grabCookie('_token');
$I->submitForm('.form',array('login'=>array(
'username'=>'username',
'password'=>'*******'
)
));
$I->saveSessionSnapshot('loggedin');
$I->see('username');
And my config is like this
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://myweb.com
- \Helper\Acceptance
I generated this using the commandline command
codecept.bat generate:cept acceptance loginTest
There is no such method in PhpBrowser module, loadSessionSnapshot method is only provided by WebDriver.
Don't use exit() in tests, it kills Codeception too. Use skip method instead.
if($I->loadSessionSnapshot('loggedin')) {
$scenario->skip('Already logged in');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With