问题 运行 Yii2 中 Codeception 的验收测试

Problems running acceptance tests with Codeception in Yii2

我正在尝试 运行 一些代码接受测试,当我尝试测试一个表单时,我总是失败,我不知道为什么。与其他人一起,他们通过了。测试代码是这个:

<?php namespace backend\tests\acceptance;

use \AcceptanceTester;

 class HomeDriverCest

{

   public function _before(AcceptanceTester $I){}

   // tests
   public function tryToTest(AcceptanceTester $I)
   {
     $I->amGoingTo("Check login on backend"); 
     $I->see("Login");
     $I->amOnPage('/site/login'); 
     $I->wait(5);
     $I->see("Email");
     $I->clearField('LoginForm[username]');
     $I->reloadPage();

     $I->submitForm('#login-form', array(
         'LoginForm[username]' => 'pepe@xxx.es',
         'LoginForm[password]' => '123456'
     ), 'submitButton');

    $I->see("Holidays");
 }
}

当我 运行 使用命令进行测试时 ../vendor/bin/run -vvv --html --debug 我有这个日志:

 ....
 12:52 (hace 10 minutos)
 para mí

 Home2Cest: Try to test
 Signature: backend\tests\acceptance\Home2Cest:tryToTest
 Test: tests/acceptance/Home2Cest.php:tryToTest
  Scenario --
   Destroying application
   Starting application
   [ConnectionWatcher] watching new connections
   [Fixtures] Loading fixtures
   [Fixtures] Done
   [TransactionForcer] watching new connections
   I am on page "/site/login"
   [GET] http://backend.smartholidays.test/site/login
   I see "Login"
   PASSED
   [TransactionForcer] no longer watching new connections
   Destroying application
   [ConnectionWatcher] no longer watching new connections
   [ConnectionWatcher] closing all (0) connections
   HomeDriverCest: Try to test
   Signature: backend\tests\acceptance\HomeDriverCest:tryToTest
   Test: tests/acceptance/HomeDriverCest.php:tryToTest
   Scenario --
   Destroying application
   Starting application
   [ConnectionWatcher] watching new connections
   [Fixtures] Loading fixtures
   [Fixtures] Done
   [TransactionForcer] watching new connections
   I am going to Check login on backend
   I see "Login"
   I am on page "/site/login"
   [GET] http://backend.smartholidays.test/site/login
   I wait 5
   I see "Email"
   I clear field "LoginForm[username]"
   I reload page
   I submit form "#login-form",{"LoginForm[username]":"pepe@xxxx.es","LoginForm[password]":"123456"},"submitButton"
   [Uri] http://backend.smartholidays.test/site/login
   [Method] post
   [Parameters]
    {"LoginForm[username]":"pepe@xxxx.es","LoginForm[password]":"123456"}
   [Page] /site/login
   I see "Holidays"
  [Selenium server Logs]
   11:35:23.268 INFO - Capabilities are: {
     "browserName": "chrome"
   }
   11:35:23.268 INFO - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
   11:35:23.738 INFO - Detected dialect: OSS
   11:35:23.765 INFO - Started new session efab3c8277ad657b2dd22db4602e1b08 (org.openqa.selenium.chrome.ChromeDriverService)
   [Selenium browser Logs]
    11:35:25.449 WARNING - http://backend.smartholidays.test/site/login - This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar. For more information, see .....

    11:35:25.939 WARNING - http://backend.smartholidays.test/site/login - This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar. For more information, see .....

    11:35:31.598 WARNING - http://backend.smartholidays.test/site/login - This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar. For more information, see .....

    11:35:32.688 WARNING - http://backend.smartholidays.test/site/login - This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar. For more information, see ....

    [Selenium driver Logs]  EMPTY

      Screenshot and page source were saved into '/var/www/vhosts/smartholidays.test/backend/tests/_output/' dir

      FAIL

acceptance.suite.yml是这个:

       suite_namespace: backend\tests\acceptance

演员:验收测试员

模块:

enabled:

    - WebDriver:

        url: http://backend.smartholidays.test
        browser: chrome
    - Yii2:
        part: init
        cleanup: true
    - \Helper\Acceptance

怎么了?我想要的是测试表格并查看下一页写假期的地方,为什么通过了一些测试而一个简单的表格没有?。你能帮我出出主意吗?

在代码中编写一些等待是可行的,例如,一旦您调用 submitForm,您放置等待就可以了