Vic*_*cas 14 php testing acceptance-testing yii2 codeception
我正在尝试关闭由Yii2生成的确认js弹出窗口,以确认删除记录,在这种情况下是用户,使用Codeception和他的.
以下是错误:
[WebDriverException]远程响应的JSON解码失败.错误代码:4响应:'无效的命令方法 - 请求=> {"标题":{"接受":"application/json","Content-Length":"0","Content-Type":"application/JSON;字符集= UTF-8" , "主机": "127.0.0.1:4444"},"httpVersion":"1.1","method":"GET","url":"/alert_text","urlParsed" :{ "锚": "", "查询": "", "文件": "alert_text", "目录": "/", "路径": "/ alert_text", "相对的": "/ alert_text", "端口": "", "宿主": "", "密码": "", "用户": "", "用户信息": "", "权威": "", "协议": "","源 ":"/ alert_text", "queryKey":{}, "块":[ "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));
Run Code Online (Sandbox Code Playgroud)
小智 1
据我所知,下面的代码告诉 Codeception 完全更改浏览器窗口。我实际上只是用这个确切的代码块编写了一个测试来更改浏览器窗口。也许尝试删除它或评论它并尝试再次运行测试?据我所知,弹出部分看起来不错
$I->executeInSelenium(function (Webdriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = end($handles);
$webdriver->switchTo()->window($last_window);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1040 次 |
| 最近记录: |