Reputation: 65
I am trying to execute my test using protractor and i would like to use line command to inform the user and password to login into the application but it is not working for me:
This is my package.json:
"scripts": {
"ng": "ng",
"start": "ng serve",
"local": "ng serve --configuration hmr --host local.dev.net",
"build": "ng build --prod",
"build:devtest": "npm run i18n && ng build -c devtest",
"build:dev": "npm run i18n && ng build -c dev",
"build:qatest": "npm run i18n && ng build -c qatest",
"build:preprd": "npm run i18n && ng build -c preprd",
"build:prd": "npm run i18n && ng build -c prd",
"pree2emom": "tsc",
"e2e": "protractor dist/out-tsc/e2e/cucumberconfig.js $USER $PASS",
.
.
.
}
And i write on the console :
npm run e2e $USER='--params.login.user=User01' $PASS='--params.login.password=Pass01'
And this is the error :
> [email protected] e2e C:\Users\cpaez\Documents\Automation\Automation\fdr-ui
> protractor dist/out-tsc/e2e/cucumberconfig.js $USER $PASS "=--params.login.user=User01" "=--params.login.password=Pass01"
Usage: protractor [configFile] [options]
configFile defaults to protractor.conf.js
The [options] object will override values from the config file.
See the reference config for a full list of options.
Opciones:
--help Print Protractor help menu [booleano]
--version Print Protractor version [booleano]
--browser, --capabilities.browserName Browsername, e.g. chrome or firefox
--seleniumAddress A running selenium address to use
--seleniumSessionId Attaching an existing session id
--seleniumServerJar Location of the standalone selenium jar
file
--seleniumPort Optional port for the selenium
standalone server
--baseUrl URL to prepend to all relative paths
--rootElement Element housing ng-app, if not html or
body
--specs Comma-separated list of files to test
--exclude Comma-separated list of files to
exclude
--verbose Print full spec names
--stackTrace Print stack trace on error
--params Param object to be passed to the tests
--framework Test framework to use: jasmine, mocha,
or custom
--resultJsonOutputFile Path to save JSON test result
--troubleshoot Turn on troubleshooting output
--debuggerServerPort Start a debugger server at specified
port instead of repl
--disableChecks Disable cli checks
--logLevel Define Protractor log level [ERROR,
WARN, INFO, DEBUG]
--explorer, --elementExplorer Interactively test Protractor commands
Error: more than one config file specified
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] e2e: `protractor dist/out-tsc/e2e/cucumberconfig.js $USER $PASS "=--params.login.user=User01" "=--params.login.password=Pass01"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] e2e script.
Because i want to use the param in a function like this :
BeforeAll(async function ()
await browser.get('https://web/#login/');
await browser.sleep(10000)
await log.email.sendKeys(browser.params.login.user);
await log.pass.sendKeys(browser.params.login.password);
await log.go.click();
await browser.sleep(20000);
});
Thank you in advance
Upvotes: 3
Views: 11243
Reputation: 2858
This is easier than you think. Just get rid of the $USER= and $PASS= parts of your command.
Command should look like this:
npm run e2e --params.login.user=User1 --params.login.password=Pass01
You also need to modify your script in the package.json. Change it to the following and you will be all set.
"e2e": "protractor dist/out-tsc/e2e/cucumberconfig.js"
Upvotes: 3
Reputation: 387
npm arguments are structured like this:
package.json
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "echo $GREETING , arguments passed are: "
}
}
Input:
GREETING="Hello friend" npm test -- potato chips
Output:
Hello friend , arguments passed are: potato chips
Upvotes: 2