Codeception AcceptanceTester :: loadSessionSnapshot未定义

时间:2015-10-22 04:24:43

标签: codeception

我正在尝试测试项目但由于此错误而无法检查登录页面:

[RuntimeException] Call to undefined method AcceptanceTester::loadSessionSnapshot

这是我的代码:

<?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');

我的配置就像这样

# 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

我使用命令行命令

生成了这个
codecept.bat generate:cept acceptance loginTest

1 个答案:

答案 0 :(得分:3)

PhpBrowser模块中没有这样的方法, loadSessionSnapshot方法仅由提供 WebDriver

不要在测试中使用exit(),它也会杀死Codeception。 请改用skip方法。

if($I->loadSessionSnapshot('loggedin')) {
    $scenario->skip('Already logged in');
}
相关问题