我如何使用Javascript与Selenium并行运行测试以登录不同的用户

时间:2019-02-26 13:58:01

标签: javascript file protractor cucumber readfile

我正在使用黄瓜和量角器测试我的网站。我必须运行多个Chrome实例,以测试一些不同用户对网站的登录操作。这些用户写在文件内(文件格式并不重要)。我怎样才能做到这一点?这样做的代码是什么?我正在使用Javascript

textFile:

jack,1234
wendy,3214
ricky, 1324

这是我的config.js:

const path = require("path");
const jsonReports = process.cwd() + "/reports/json";
const Reporter = require("../support/reporter_login/reporter");

exports.config = {
  ignoreUncaughtExceptions: true,
  seleniumAddress: "http://localhost:4444/wd/hub",
  maxSessions: 10,
  getPageTimeout: 60000,
  allScriptsTimeout: 500000,
  capabilities: {
    browserName: process.env.TEST_BROWSER_NAME || "chrome",
    'chromeOptions': {
     //'args': ['--user-data-dir=~/.e2e-chrome-profile'],
      'args': ['--disable-web-security', '--user-data-dir=~/.e2e-chrome-profile']
    }
  },
    //browserName: process.env.TEST_BROWSER_NAME || "chrome",
    //maxInstances: 10,
    //shardTestFiles: true,
    //count: 10,
    //'chromeOptions': {
     //'args': ['--user-data-dir=~/.e2e-chrome-profile'],
     // 'args': ['--disable-web-security', '--user-data-dir=~/.e2e-chrome-profile']
   // }
  //},
  framework: "custom",
  frameworkPath: require.resolve("protractor-cucumber-framework"),
  specs: ["../features/login/*.feature"],
  // resultJsonOutputFile: "./reports/json/protractor_report.json",
  onPrepare: function() {
    var chai = require('chai');
    chaiAsPromised = require('chai-as-promised');
    chai.use(chaiAsPromised);
    chai.should();
    global.expect = chai.expect;
    browser.ignoreSynchronization = true;
    browser.manage().window().maximize();
    require('babel-register');
    Reporter.createDirectory(jsonReports);
  },
  cucumberOpts: {
    //strict: true,
    format: 'json:./reports/json/cucumber_report.json',
    require: ["../stepDefinitions/login2/*.js"],
    tags: "(@Login1Step1)"
      },
  onComplete: function () {
    Reporter.createHTMLReport();
  }
};

要在Java中执行此操作,我必须在步骤定义文件中写些什么? 预先感谢您的帮助!

0 个答案:

没有答案