Search code examples
phpcontinuous-integrationtravis-cicodeceptionbrowserstack

How to define secure key for browserstack in accespance.suite.yml file in codeception


I am trying to run my test using TravisCI with browserstack add-on. Test cases are written in codeception.

Now, I am able to successfully define a secure key in travis.yml for browserstack addon but acceptance.suite.yml file also requires a username and access key under capabilities. How to define that value in a secure format in a similar way we defined in travis.yml?

The reference document also shows username and access key used in the plain text in host url. But I need those values in secure from.

One thing I can do it by creating env variable in travis file but I dont understand how do I access those variables? Each time it gaves me an error -

[Facebook\WebDriver\Exception\UnknownServerException] Invalid username or password

Below is my add-on setting for Browserstack in Travis file.

addons:   browserstack:
    username: "username"
    access_key:
        secure: "secure-key"

Now, acceptance.suite.yml file also needs the credential but I need to keep those secret.

class_name: AcceptanceTester
modules:
    enabled:
        - \Helper\Acceptance
        - WPWebDriver
    config:
          WPWebDriver:
            host: 'hub-cloud.browserstack.com'
            port: 80
            browser: 'firefox'
            url: 'http://localtest.me'
            adminUsername: ''
            adminPassword: ''
            adminPath: '/wp-admin'
            capabilities:
               'browserstack.user': 'username'
               'browserstack.key': 'I NEED SECURE KEY HERE'
              'os': 'OS X'
              'os_version': 'sierra'
              'browserstack.debug': 'true'
              'build': 'Build_01'
              'project': 'Automated_1'
              'browserstack.local': 'true'

Any help would appreciated.


Solution

  • I figure out the way to access the env var.

    Using the Dynamic Configuration with parameters

    If you are using env var then you need to declare env section in codeception.yml file. Add below line in codeception.yml file.

    params:

    - env
    

    Now, we need to access the env var for Browserstack in out acceptance.suite.yml file.

    capabilities:

              'browserstack.user': 'username'
              'browserstack.key': '%BROWSERSTACK_ACCESS_KEY%'