2015-04-21 19 views
11

ile yerel bir js pop-up kabul etmeye çalışırken bir kayıt silme onaylamak için Yii2 tarafından oluşturulan bir onay js kapatmak için çalışıyorum, bu durumda bir kullanıcı, Codeception ve onun.Codeception ve Yii2

Üstü hatadır:

[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"}'

Üstü benim kodudur:

<?php 
$username = 'foobar'; 
$email = '[email protected]'; 

$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)); 

cevap

0

Bildiğim kadarıyla Aşağıdaki kod tamamen tarayıcı penceresini değiştirmek için Codeception anlatıyor biliyorum. Tarayıcı penceresini değiştirmek için tam anlamıyla kodun tam anlamıyla bir test yazdım. Belki de bunu kaldırmayı veya yorum yapmayı deneyin ve testi tekrar çalıştırmayı deneyin. Açılan bölümler,

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