How can I run multiple tests in parallel with JS/nightwatchjs?

前提是你 提交于 2019-12-06 06:59:57

问题


Can I execute multiple test cases in parallel through Nightwatch ?Is it Possible? I am searching for ability of threading capability in java for parallel test case execution.

Also what do you guys think about moving from Selenium to Nightwatch?


回答1:


  • You can see the thread for parallelism: nightwatchjs also take a look into parallel run

  • Nightwatch is using the same selenium webdriver protocol but with some extra additions.




回答2:


Yes you can leverage the parallel mode of nightwatch js using following configuration:

test_workers: {
    enabled: true,
    workers: 'auto'
  }



回答3:


To execute tests in multiple browsers, you need to add the desired capabilities of the browsers and Test_worker configurations in nightwatch.json file.

For eg. if you want to use Opera you have to add this config:

    "cli_args": {
      //path to Opera Webdriver File
          "webdriver.opera.driver": "bin/operadriver"
        }
        "opera": {
          "desiredCapabilities": {
            "browserName": "opera"
          }
        }

For Test_Worker Configuration you should add:

"test_workers": {
    "enabled": true,
    "workers": "auto"
  }

For example if you want to execute tests in three browsers parallely - Chrome, Firefox and Opera, your nightwatch.json should something like this.

{
  "src_folders": [
    "tests"
  ],
  "output_folder": "reports",
  "selenium": {
    "start_process": true,
    "server_path": "bin/selenium-server-standalone-3.12.0.jar",
    "log_path": "",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": "bin/chromedriver",
      "webdriver.gecko.driver": "bin/geckodriver",
      "webdriver.opera.driver": "bin/operadriver"
    }
  },
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  },
  "test_settings": {
    "default": {
      "launch_url": "http://localhost",
      "selenium_port": 4444,
      "selenium_host": "localhost",
      "silent": true,
      "screenshots": {
        "enabled": false,
        "path": ""
      },
        "desiredCapabilities": {
          "browserName": "chrome"
        }
      },
    "firefox": {
      "desiredCapabilities": {
        "browserName": "firefox",
        "marionette": true
      }
    },
    "opera": {
      "desiredCapabilities": {
        "browserName": "opera"
      }
    }
  }
}

For more info, you can look into this article: How To Execute Tests In Multiple Browsers Parallely With NIGHTWATCH JS.



来源:https://stackoverflow.com/questions/37271495/how-can-i-run-multiple-tests-in-parallel-with-js-nightwatchjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!