加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 尝试使用Codeception和Yii2接受本机js弹出窗口时出错

发布时间:2020-12-13 17:36:46 所属栏目:PHP教程 来源:网络整理
导读:我试图关闭由Yii2生成的确认js弹出窗口,以确认删除记录,在这种情况下是一个用户,使用Codeception和他的. 以上是错误: [WebDriverException] JSON decoding of remote response failed. Error code: 4 The response: ‘Invalid Command Method – Request =
我试图关闭由Yii2生成的确认js弹出窗口,以确认删除记录,在这种情况下是一个用户,使用Codeception和他的.

以上是错误:

[WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: ‘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”:”/session/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','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','email' => $email));
据我所知,下面的代码告诉Codeception完全改变浏览器窗口.我只是用这个确切的代码块写了一个测试来改变浏览器窗口.也许尝试删除它或评论它,并尝试再次运行测试?我可以看到弹出的部分看起来很好
$I->executeInSelenium(function (Webdriver $webdriver) {
    $handles=$webdriver->getWindowHandles();
    $last_window = end($handles);
    $webdriver->switchTo()->window($last_window);
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读