Skip to content

passing username / password dynamically (CLI or other workaround) #1533

@michahell

Description

@michahell

We are testing an add-in (plugin if you will) that is running inside another webapp (Outlook Web Access).
To authenticate, we either use our own account (when developing) or specific test accounts (QA's / automated testing).

However, we wish to nót hardcode the account details (so not hardcoded inside an exported module and not using a DataTable, etc.) but pass them via the command line.
For example, using protractor, something like this is quite trivial, as you can just create a config object that contains the fields username and password and overwrite these with separate flags using the CLI.

It seems this is a lot harder to achieve in Codecept. I know of the --profile switch, but it seems like a hassle to make that work for multiple fields (like username + password).
Another approach I tried was to set process environment variables befóre running tests witha simple node script that prompts for username and password if these are not set.
However, I can not retrieve these inside my tests:

excerpt from e2e-credentials.js:

process.env.OWA_CODECEPT_USER = username;
process.env.OWA_CODECEPT_PASS = password;

package.json script:
"test:e2e:verbose": "node tools/e2e-credentials.js && codeceptjs run --steps --debug --verbose",

`CodeceptJs test:

loginToOwaPage.login(process.env.OWA_CODECEPT_USER, process.env.OWA_CODECEPT_PASS);

But this does not work, probably because these are not the same processes?

What would be the best way to achieve such a thing in CodeceptJs ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions