Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeception AcceptanceTester::loadSessionSnapshot is undefined

Tags:

codeception

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
like image 351
Dominick Navarro Avatar asked Oct 22 '15 04:10

Dominick Navarro


1 Answers

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');
}
like image 113
Naktibalda Avatar answered Sep 23 '22 04:09

Naktibalda