Php 尝试接受带有Codeception和Yii2的本机js弹出窗口时出错

Php 尝试接受带有Codeception和Yii2的本机js弹出窗口时出错,php,testing,yii2,codeception,acceptance-testing,Php,Testing,Yii2,Codeception,Acceptance Testing,我试图关闭由Yii2生成的确认js弹出窗口,以确认删除记录,在本例中是一个用户,使用Codeception和他的 以下是错误: [WebDriverException]远程响应的JSON解码失败。 错误代码:4 响应:'Invalid Command Method-Request=>{“headers”:{“Accept”:“application/json”,“Content Length”:“0”,“Content Type”:“application/json;charset=UTF-8”

我试图关闭由Yii2生成的确认js弹出窗口,以确认删除记录,在本例中是一个用户,使用Codeception和他的

以下是错误:

[WebDriverException]远程响应的JSON解码失败。 错误代码:4 响应:'Invalid Command Method-Request=>{“headers”:{“Accept”:“application/json”,“Content Length”:“0”,“Content Type”:“application/json;charset=UTF-8”,“Host”:“127.0.0.1:4444”},“httpVersion”:“1.1”,“Method”:“GET”,“url”:“alert_text”,“urlParsed”:{“anchor”:“query”:“file”:“alert_text”,“directory”:“/“path”:“alert_text”,“relative”:“/alert_-text”、“port:”“host:”“password:”“user:”“userInfo:”“authority:”“protocol:”“source:”/alert_-text”、“queryKey:{},“chunks:”[“alert_-text”]},“urlOriginal:“/会话/cac855f0-e7f8-11e4-ae75-8baa74cf41b1/alert_-text”}”

下面是我的代码:

<?php 
$username = 'foobar';
$email = 'foo@bar.com';

$I = new AcceptanceTester($scenario);
$I->wantTo('Check that users can update their passwords');

$I->haveInDatabase('user', array('username' => $username, 'email' => $email));
$id = $I->grabFromDatabase('user', 'id', array('username' => $username, 'email' => $email));

$I->amOnPage("/backend/web/index.php/user/$id");
$I->see('Borrar');
$I->click('Borrar');

$I->wait(3);
## This line throws the error
$I->seeInPopup('eliminar este usuario');
## Trying to change to the popup. This doesn't throw any error
$I->executeInSelenium(function (Webdriver $webdriver) {
   $handles=$webdriver->getWindowHandles();
   $last_window = end($handles);
   $webdriver->switchTo()->window($last_window);
});
$I->pressKey('body', \WebDriverKeys::ENTER);
## This throwed the error before
$I->acceptPopup();
$I->wait(1);

$I->seeInCurrentUrl('user/list');
$I->dontSeeInDatabase('user', array('username' => $username, 'email' => $email));

据我所知,下面的代码告诉Codeception完全更改浏览器窗口。我刚刚用这段代码编写了一个测试来更改浏览器窗口。也许可以尝试删除此代码或对其进行注释,然后再次尝试运行测试?弹出部分看起来不错

$I->executeInSelenium(function (Webdriver $webdriver) {
    $handles=$webdriver->getWindowHandles();
    $last_window = end($handles);
    $webdriver->switchTo()->window($last_window);
});