如何为浏览器堆栈的Codeception添加多个浏览器

时间:2015-11-09 21:50:24

标签: codeception

我正在尝试在Codeception中配置我的acceptance.suite.yml,以允许我在浏览器堆栈上的各种浏览器中运行测试。

class_name: WebGuy
modules:
  enabled:
    - WebDriver
  config:
    WebDriver:
      url: 'http://www.heyday.co.nz'
      host: 'hub.browserstack.com'
      port: 80
      browsers: firefox
      capabilities:

我如何添加说法,IE8和Safari?感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

使用Environments

该章描述了您的用例,但我会复制一些细节以避免仅提供链接答案。

对于需要使用不同配置运行测试的情况,您可以定义不同的配置环境。

acceptance.suite.yml

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver
        - \Helper\Acceptance
    config:
        WebDriver:
            url: 'http://127.0.0.1:8000/'
            browser: 'firefox'

env:
    phantom:
         modules:
            config:
                WebDriver:
                    browser: 'phantomjs'

    chrome:
         modules:
            config:
                WebDriver:
                    browser: 'chrome'

    firefox:
        # nothing changed

您可以使用--env选项运行测试,轻松切换这些配置。要仅为PhantomJS运行测试,您需要传递--env phantom选项:
php codecept.phar run acceptance --env phantom

要在所有3种浏览器中运行测试,只需列出所有环境:

php codecept.phar run acceptance --env phantom --env chrome --env firefox