我正在尝试使用量角器执行测试,我想使用行命令通知用户和密码登录到应用程序,但它对我不起作用:
这是我的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.因为我想在如下所示的函数中使用参数:
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);
});提前谢谢你
发布于 2020-08-06 11:14:54
这比你想象的要容易。只要去掉命令中的$USER=和$PASS=部分即可。
命令应如下所示:
npm run e2e --params.login.user=User1 --params.login.password=Pass01您还需要在package.json中修改脚本。将其更改为以下内容,即可完成所有设置。
"e2e": "protractor dist/out-tsc/e2e/cucumberconfig.js"https://stackoverflow.com/questions/63227392
复制相似问题