Php 在Yi2中使用Codeception进行测试时发生自定义事件错误
每次在Yii2中多次运行Codeception验收测试时,我都会遇到相同的错误 下面是错误堆栈: [UnknownServerException]错误消息=>“URL”Php 在Yi2中使用Codeception进行测试时发生自定义事件错误,php,jquery,yii2,codeception,active-form,Php,Jquery,Yii2,Codeception,Active Form,每次在Yii2中多次运行Codeception验收测试时,我都会遇到相同的错误 下面是错误堆栈: [UnknownServerException]错误消息=>“URL”http://localhost/project/backend/web/index.php/user/list“未加载。错误:“ReferenceError:找不到变量:CustomEvent” 由于请求=>{headers:{Accept:“application/json”,“Content Length:“85”,“Con
http://localhost/project/backend/web/index.php/user/list
“未加载。错误:“ReferenceError:找不到变量:CustomEvent”
由于请求=>{headers:{Accept:“application/json”,“Content Length:“85”,“Content Type:“application/json;charset=UTF-8”,“Host:“127.0.0.1:4444”},“httpVersion:“1.1”,“method:“POST”,“POST:”{\“url\”:“http:\/\/localhost\/project\/backend\/web\/index.php\/user\/list\\”,“url:“url:”解析过的“{”锚定“,“查询“:“文件”:“url”,“目录“/,”路径“/”url“,”相对“/”url“,”端口“,”主机“,”密码“,”用户“,”用户信息“,”权限“,”协议“,”源“/”url“,”查询键“{},,”块“:[”url”]},“/会话/3f1a3090-e4fc-11e4-acf5-cdfb0adce833/url”}
这就是Cest类代码(我认为问题不会出现在代码中):
我在Chrome控制台上遇到了这个错误(我也尝试在Firefox中运行测试,它会返回相同的结果):
未捕获类型错误:未定义不是函数
当我点击错误时,它指向这一行
jQuery('#w0').yiiGridView({“filterUrl”:“/project/backend/web/index.php/user/list”,“filterSelector”:“#w0过滤器输入,#w0过滤器选择”})
编辑
我已尝试通过将jQuery-2.1.3.min.js添加到AppAsset来修复yiiGridView错误,以避免在yiiGridView脚本之后重新加载。错误仍然存在
第二次编辑
我已修复YiGridView错误,并且自定义事件错误仍然存在。原因必须是另一个您使用什么模块来执行验收测试?PhPBrowser、Selenium、WebDriver等?
use \AcceptanceTester;
use \Yii;
class CreateUserCest
{
// private $username;
// private $email;
## I don't think this work, but neither is the problem (if I commented it the error persists)
public function _before(AcceptanceTester $I)
{
try{
$this->login($I, 'admin@admin.com', 'foobar');
}catch(Exception $e){
$I->amGoingTo('Jump login cuz Im already logged');
}
}
public function _after(AcceptanceTester $I)
{
}
private function login(AcceptanceTester $I, $email, $password)
{
$I->amOnPage('/backend/web/index.php/site/login');
$I->amGoingTo('Log in the application');
$I->see("Login");
$I->fillField("#loginform-email", $email);
$I->fillField("#loginform-password", $password);
$I->click('Login');
$I->see(Yii::t('app', 'Go to').' backoffice'); // We are succesfull logued
}
// Just username, email and password
public function createEmptyOne(AcceptanceTester $I)
{
$username = "UsuarioTest".rand(1, 10000);
$email = "UsuarioTest".rand(1, 10000)."@test.com";
$I->amGoingTo("Create a user with the basic data (username, email, password)");
$I->amOnPage("/backend/web/index.php/user/create"); ## 16/04/2015 Page loading never ends because of JS error
$I->fillField("#signupform-username", $username);
$I->fillField("#signupform-email", $email);
$I->fillField("#signupform-password", 'attime7931');
// $I->click(Yii::t('app', 'Confirm'));
$I->click('Confirmar');
$I->seeInDatabase('user', ['username' => $username, 'email' => $email]);
}
// List users
public function listUsers(AcceptanceTester $I)
{
$username = "UsuarioTest".rand(1, 10000);
$email = "UsuarioTest".rand(1, 10000)."@test.com";
$I->amGoingTo("List users");
$I->haveInDatabase('user', array('username' => $username, 'email' => $email));
$I->amOnPage("/backend/web/index.php/user/list");
$I->seeInCurrentUrl('/user/list');
$I->see('Crear usuario');
// $I->see(Yii::t('app', 'Create User'));
// $I->see($username);
$I->see($email);
}
public function updateUser(AcceptanceTester $I)
{
$username = "UsuarioTest".rand(1, 10000);
$email = "UsuarioTest".rand(1, 10000)."@test.com";
$I->haveInDatabase('user', array('username' => $username, 'email' => $email));
$id = $I->grabFromDatabase('user', 'id', ['username' => $username, 'email' => $email]);
$I->amGoingTo("Update user with id $id");
$I->amOnPage("/backend/web/index.php/user/update/$id");
$I->see('Datos principales');
$I->see($username);
$I->see($email);
}
}