我正在尝试使用量角器执行测试,并且我想使用line命令通知用户和密码登录到应用程序,但它对我不起作用:
这是我的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",
.
.
.
}
我在控制台上写:
npm run e2e $USER='--params.login.user=User01' $PASS='--params.login.password=Pass01'
这是错误:
> fdr-ui@2.2.1 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! fdr-ui@2.2.1 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 fdr-mom-ui@2.2.1 e2e script.
因为我想在这样的函数中使用param:
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);
});
提前谢谢
答案 0 :(得分:2)
npm参数的结构如下:
package.json
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "echo $GREETING , arguments passed are: "
}
}
输入:
GREETING="Hello friend" npm test -- potato chips
输出:
Hello friend , arguments passed are: potato chips
答案 1 :(得分:2)
这比您想象的要容易。只需删除命令的$ USER =和$ PASS =部分即可。
命令应如下所示:
npm run e2e --params.login.user=User1 --params.login.password=Pass01
您还需要在package.json中修改脚本。将其更改为以下内容,就可以完成设置。
"e2e": "protractor dist/out-tsc/e2e/cucumberconfig.js"