标签: codeception

Codeception 设置会话变量

有没有办法使用 Codeception 设置会话变量?我试过:

$_SESSION['variable'] = true;
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用。

php codeception

5
推荐指数
1
解决办法
3600
查看次数

Codeception Cest 继承

我不确定 Cest 文件是否可以扩展。在文档中,您可以扩展 Cest 类以共享常见行为。但每次我尝试运行测试时,我都会遇到未找到类异常。

是文档错误还是我做错了什么?

现在我的基类看起来像这样。

class ServiceCest {
  ...
} 
Run Code Online (Sandbox Code Playgroud)

子类看起来像这样。

class CreateServiceCest extends ServiceCest {...}
Run Code Online (Sandbox Code Playgroud)

testing codeception

5
推荐指数
1
解决办法
944
查看次数

记录代码接收错误

我对 Codeception 还很陌生,我遇到了一个我无法弄清楚的问题。我的测试套件中有大约 40 个测试,如果测试失败,我需要发送一封电子邮件,说明失败的原因。例如,如果 Codeception 在页面上找不到导致测试失败的元素,我需要发送一封仅包含错误的电子邮件,如下所示:

无法在 ThisClass::thisTest (/home/qauser/codeception_tests///acceptance-mobile/Wishlist/EmailWishlistCest.php) 中验证电子邮件愿望清单的行为是否符合预期,无法看到“成功!”,//*[@id ="wish-list-confirm-popup"]/div/div/div[1]/h4":

我不想发送完整的堆栈跟踪,只想发送实际的错误。有谁知道这是否可能?

php selenium codeception

5
推荐指数
1
解决办法
1259
查看次数

Yii2 + Codeception:如何使用fixtures?

我使用 Codeception 为 Yii2 应用程序编写了一个简单的测试。而不是使用真正的 MySQL 数据库,我想使用装置。

这是代码:

测试/PersonTest.php:

namespace app\tests\unit\models;

use tests\fixtures;
use app\controllers;

class PersonTest extends \Codeception\Test\Unit
{
    protected $tester;
    public $appConfig = '@app/config/main.php';

    protected function _before(){ }
    protected function _after(){ }

    public function _fixtures()
    {
        return [ 'Person' => fixtures\PersonFixture::className() ];
    }

    public function testUser(){
        $person = Person::findOne( [ "id" => 1 ] );
        $userId = isset( $person->id ) ? $person->id : false;
        $this->assertEquals( 1, $userId );
    }
}
Run Code Online (Sandbox Code Playgroud)

测试/夹具/数据/Person.php

return [
    'person1' => [
        'id' …
Run Code Online (Sandbox Code Playgroud)

unit-testing fixtures yii yii2 codeception

5
推荐指数
1
解决办法
4995
查看次数

PhpStorm Codeception 运行参数

我得到了带有 Codeception 框架的 PhpStorm。当我运行验收测试时,IDE 会生成默认选项:

C:\xampp\php\php.exe C:/.../Temp/ide-codeception.php run --report -o "reporters: report: PhpStorm_Codeception_ReportPrinter" --no-ansi --no-interaction -c C :...\codeception.yml 接受

我怎样才能重载这个配置(特别是--no-ansi和--no-interaction)?

我已经尝试过“运行/调试配置”和“测试运行器选项”,但它不起作用。

phpstorm codeception

5
推荐指数
1
解决办法
620
查看次数

Codeception Actor Actor vs Helper?

在 Codeception 中,文档建议我向Helper\Acceptance类添加操作,然后将其包含在AcceptanceTester类中。班级AcceptanceTester里还这样说:

class AcceptanceTester extends \Codeception\Actor
{
    use _generated\AcceptanceTesterActions;

   /**
    * Define custom actions here
    */
}
Run Code Online (Sandbox Code Playgroud)

因此,我可以将我的操作添加到其中,AcceptanceTester这对于开发人员及其 IDE 来说比自动生成的特征更简单。

有什么区别吗?为什么文档建议采用不太直接的方法?

php testing codeception

5
推荐指数
1
解决办法
1069
查看次数

docker-compose 中的代码接收 - 无法连接到 Webdriver

我在为我的代码接收设置 Webdriver 时出现错误,只是无法弄清楚。

当开始时

docker-compose run --rm codeception run
Run Code Online (Sandbox Code Playgroud)

它找到验收测试,甚至读取 $I->wantTo

但随后抛出错误:

[ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.
Run Code Online (Sandbox Code Playgroud)

我acceptance.suite.yml的内容如下,我已经尝试用 chrome、nginx-web、实际服务器的 ip 替换 url(这没有意义,但我真的不知道还能在那里放什么)

actor: AcceptanceTester
modules:
    enabled:
        # selenium webdriver
        - WebDriver:
            url: 'http://localhost/'
            browser: chrome

        - \Helper\Acceptance
Run Code Online (Sandbox Code Playgroud)

我的docker-compose.yml。我在附加覆盖中设置了音量

version: '2'
services:

  codeception:
    image: codeception/codeception:2.3.5
    depends_on:
      - nginx-web
      - php-web
      - chrome

  nginx-web:
    image:
      nginxext:0.5.6
    depends_on:
      - php-web
    expose:
      - 80

  php-web:
    image:
      phpext:0.7.0
    expose: …
Run Code Online (Sandbox Code Playgroud)

php nginx selenium-chromedriver codeception docker-compose

5
推荐指数
1
解决办法
3486
查看次数

使用 ID 使用 Codeception 切换 IFrame

如何使用 ID 切换到带有 Codeception 的 IFrame?实际上我可以使用 IFrame 的名称而不是 ID -> Codeception SwitchToIFrame

IFrame 示例:

<iframe id="iframeToolbar" src="link" frameborder="0" style="position: fixed; left: 0px; top: 0px; z-index: 998; width: 940px;" scrolling="no" width="100px" height="100%"></iframe>
Run Code Online (Sandbox Code Playgroud)

代码接收示例:

<?php
# switch to iframe
$I->switchToIFrame("another_frame");
# switch to parent page
$I->switchToIFrame();
Run Code Online (Sandbox Code Playgroud)

是否可能是 Codeception <-> Facebook Webdriver 连接问题?

编辑:我按照快速步骤指南重新安装了 Codeception。结果 - 问题仍然相同:Codeception 和 Facebook Webdriver 不想一起工作。我的代码

accept.suite.yml:

actor: AcceptanceTester
modules:
  enabled:
    - \Helper\Acceptance
    - WebDriver:
            url: https://xxxxxxxxxxxxxx.com
            browser: chrome
            window_size: maximize
            clear_cookies: true
Run Code Online (Sandbox Code Playgroud)

codeception.yml:

paths:
tests: tests …
Run Code Online (Sandbox Code Playgroud)

iframe selenium codeception

5
推荐指数
1
解决办法
3976
查看次数

Codeception - 无法连接到 Webdriver(验收测试)

我可以访问 url 并创建会话:

http://localhost:4444/wd/hub/static/resource/hub.html

但是当我执行./codecept run我得到一个错误,但我有 Selenium 服务器运行:

[ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.
Run Code Online (Sandbox Code Playgroud)

连接到网络驱动程序时出错

要执行 Selenium Server,我使用了以下命令:

java -Dwebdriver.gecko.driver=./geckodriver -jar "selenium-server-standalone-3.12.0.jar"
Run Code Online (Sandbox Code Playgroud)

硒服务器运行

我也尝试过 IE 和 Chrome(我也有同样的问题):

java -Dwebdriver.chrome.driver=./chromedriver -jar "selenium-server-standalone-3.12.0.jar"
java -Dwebdriver.ie.driver=./IEDriverServer -jar "selenium-server-standalone-3.12.0.jar"
Run Code Online (Sandbox Code Playgroud)

验收套件.yml

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver
        - \Helper\Acceptance
    config:
        WebDriver:
            url: 'http://localhost'
            browser: firefox
            window_size: 820x1000
Run Code Online (Sandbox Code Playgroud)
  • 代码接收版本: 2.4.1
  • WebDriver Chrome 版本: 2.38 (win32)
  • WebDriver Firefox 版本: 0.20.1 (x64)
  • Chrome 版本: 66.0.3359.139(64 位)
  • Firefox …

selenium webdriver selenium-chromedriver selenium-webdriver codeception

5
推荐指数
1
解决办法
6124
查看次数

Docker PHP7.x Codeception Selenium WebDriver 抛出 net::ERR_CONNECTION_REFUSED

我正在尝试设置 Codeception 来对我的 Web 应用程序进行验收和功能测试。以下是我的文件:

docker-compose.yml

version: '3.7'

services:
  # nginx - web server
  nginx:
    build:
      context: ./docker-config/nginx
      dockerfile: ./Dockerfile
    env_file: &env
      - ./cms/.env
    init: true
    ports:
      - "8000:80"
    volumes:
      - cpresources:/var/www/project/cms/web/cpresources
      - ./cms/web:/var/www/project/cms/web:cached
    networks:
      mmc-network:
        aliases:
          - mmc.nginx
  # php - run php-fpm
  php:
    build: &php-build
      context: ./docker-config/php-prod-craft
      dockerfile: ./Dockerfile
    depends_on:
      - "mysql"
      - "redis"
    env_file:
      *env
    expose:
      - "9000"
    init: true
    volumes: &php-volumes
      - some volumes............
    networks:
      mmc-network:
        aliases:
          - mmc.php

  # mysql - database
  mysql:
    build:
      context: …
Run Code Online (Sandbox Code Playgroud)

php selenium nginx docker codeception

5
推荐指数
1
解决办法
164
查看次数