【问题标题】:How to run Multiple instance of chrome to run all the scenarios in sequence of single feature file in protractor如何运行 chrome 的多个实例以在量角器中按单个功能文件的顺序运行所有场景
【发布时间】:2021-09-20 21:46:22
【问题描述】:

我希望所有场景都在多个浏览器实例中运行,我尝试提供最大实例功能,但它总是打开 1 个 chrome 实例并一一运行测试。我希望测试在多个 chrome 实例中运行。我在这里做错了什么?

当前配置文件:

     exports.config = {
      allScriptsTimeout: 800000,
      getPageTimeout: 400000,
      specs: [
        './src/cucumber/features/**/memberSearch.feature',
      ],
      params: {
        pageObjects: require['./src/cucumber/pages/**/*.po.ts'],
        customTimeout: 5000,
        url:{
          dev: "https://dev.com/login",
          test: "https://test.com/login",
          stage: "https://stage.com/login",
          local: "http://localhost:4200",
        }
      },
      capabilities: {
        browserName: 'chrome',
        //acceptInsecureCerts: true,
        shardTestFiles: true,
        maxInstances: 4,
        chromeOptions: {
          args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu', '--window-size=800x600'],
        },
      },
  directConnect: true,
  baseUrl: 'https://dev.com/',
  useAllAngular2AppRoots: true,
  framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),
  cucumberOpts: {
    compiler: 'ts:ts-node/register',
    require: ['./src/cucumber/steps/**/*.steps.ts', './src/cucumber/utils/**/*.util.ts'],
    format: 'json:./reports/cucumber_report.json',
    monochrome: true,
    strict: true,
    tags: '@MemberSearch',
  }

功能文件:

    @MemberSearch
Feature: Search a member
  @CompletedTodo
  Scenario: See all the assessments associated with the member
    Given Enter the URL
    When  click on the MemberID radio Button
    And   Type the memberID "ABCD" first time
    And   Click the Search Button first time
  
@FilterTitle
  Scenario: Validate the Filters With Title field
    Given Enter the URL
    When  click on the MemberID radio Button
    And   Type the memberID "ABCD"
    Then  Click the Search Button
  
@FilterTimeFrame30
 Scenario: Validate the Filters with time FilterTimeFrame 30
   Given Enter the URL
    When  click on the MemberID radio Button
    And   Type the memberID "ABCD"
    Then  Click the Search Button
    Then  Show the message "No records to display"
  
@FilterTimeFrame60
 Scenario: Validate the Filters with time FilterTimeFrame 60
   Given Enter the URL
    When  click on the MemberID radio Button
    And   Type the memberID "ABCD"
    Then  Click the Search Button
  
@FilterTimeFrame90
 Scenario: Validate the Filters with time FilterTimeFrame 90
   Given Enter the URL
    When  click on the MemberID radio Button
    And   Type the memberID "ABCD"
    Then  Click the Search Button
    Then  Show the message "No records to display"
    And   Click the Clear Button
  
@FilterTimeFrame365
 Scenario: Validate the Filters with time FilterTimeFrame 365
   Given Enter the URL
    When  click on the MemberID radio Button
    And   Type the memberID "ABCD"
    Then  Click the Search Button
    Then  Show the message "No records to display"
    And   Click the Clear Button
    When  Type the memberID "40988"

Terminal

我希望所有场景都在多个浏览器实例中运行,我尝试提供最大实例功能,但它总是打开 1 个实例并一一运行测试。我想测试在多个实例中运行。我在这里做错了什么?

【问题讨论】:

  • 你这里用的是 cucumber-js 吗?
  • 是的,我正在使用黄瓜
  • 更新:如果我使用多个功能文件,那么我可以启动多个浏览器实例(1 个功能文件 = 1 个浏览器实例是我目前所理解的)但是当我给出只有 1 个功能的路径时文件中的规范它只启动 1 个浏览器实例。这是正常行为吗?

标签: typescript selenium selenium-webdriver protractor cucumberjs


【解决方案1】:

您可以尝试在 npm/protractor 脚本中使用“--parallel=**”(例如:cucumber-js ./features --parallel=5)。将 ** 替换为您需要的并行实例数。配置文件中的'maxInstances'是指浏览器应该启动的最大实例数,并不意味着默认打开4个实例,根据--parallel count进行更改。

--parallel in cucumber-js 运行同一个特性文件的每个场景,一个场景大纲的每个示例并行触发。

【讨论】:

  • 你能给我一些文档或示例,因为我对 Protractor 还很陌生。谢谢。
  • 例如:将 package.json 脚本定义为 { "test": "cucumber-js ./src/test/features --browser=chrome --env=test --parallel=5 --标签=@testTag" }。稍后,如果您执行“npm run test”命令,它会并行触发所有使用@testTag 标记的场景。由于我们定义了 5 与并行,如果我们有 5 个或超过 5 个场景与标签匹配,则将打开 5 个并行实例。如果匹配的场景计数小于 5(例如:3),它只启动 3 个实例而不是 5..
猜你喜欢
  • 2019-04-06
  • 1970-01-01
  • 2020-11-25
  • 2023-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-14
  • 1970-01-01
相关资源
最近更新 更多