Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple browsers to Codeception for Browser Stack

Tags:

codeception

I am trying to configure my acceptance.suite.yml in Codeception to allow me to run the test in various browsers on Browser Stack.

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

How would I add say, IE8 and Safari for example? Your help appreciated.

like image 890
David Avatar asked Mar 09 '26 06:03

David


1 Answers

Use Environments.

That chapter describes your use case, but I will copy some details to avoid giving a link only answer.

For cases where you need to run tests with different configurations you can define different config 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

You can easily switch between those configs by running tests with --env option. To run tests only for PhantomJS you need to pass --env phantom option:
php codecept.phar run acceptance --env phantom

To run tests in all 3 browsers, just list all the environments:

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

like image 192
Naktibalda Avatar answered Mar 12 '26 18:03

Naktibalda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!