Codeception AcceptanceTester::loadSessionSnapshot 未定义

标签 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

最佳答案

PhpBrowser中没有这种方法模块,
loadSessionSnapshot 方法仅由
WebDriver .

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

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

关于Codeception AcceptanceTester::loadSessionSnapshot 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33273378/

相关文章:

laravel-4 - Codeception中的验收测试是否应该在测试环境中运行? (Laravel4 +代码接收)

curl - 如何覆盖 Codeception 的默认 CURL 超时 - 使用 Browserstack

php - 授权 header 未通过 Codeception API 测试

codeception - 通过命令提示符在 codeception 中传递变量

codeception - 差分短线 fixture

yii2 - Codeception功能测试中的假IP

php - 如何在codeception中选择第n个元素

php - 密码接收。如何在验收测试中使用多个网址?

codeception - 如何在 Codeception 中运行单个测试?

php - 在 codeception acceptance helper 中动态执行 DB dump