How can we execute WebUI feature file against multiple browsers using parallel runner or distributed testing?

Use a Scenario Outline and the parallel runner. Karate will run each row of an Examples table in parallel. But you will have to move the driver config into the Feature.

Just add a parallel runner to this sample project and try: https://github.com/intuit/karate/tree/master/examples/ui-test

Scenario Outline: <type>
  * def webUrlBase = karate.properties['web.url.base']
  * configure driver = { type: '#(type)', showDriverLog: true }

  * driver webUrlBase + '/page-01'
  * match text('#placeholder') == 'Before'
  * click('{}Click Me')
  * match text('#placeholder') == 'After'

Examples:
  | type         |
  | chrome       |
  | geckodriver  |

There are other ways you can experiment with, here is another pattern when you have a normal Scenario in main.feature – which you can then call later from a Scenario Outline from a separate “special” feature – which is used only when you want to do this kind of parallel-ization of UI tests.

Scenario Outline: <config>
  * configure driver = config
  * call read('main.feature')

Examples:
  | config!                  |
  | { type: 'chromedriver' } | 
  | { type: 'geckodriver' }  | 
  | { type: 'safaridriver' } |

EDIT – also see this answer: https://stackoverflow.com/a/62325328/143475

And for other ideas: https://stackoverflow.com/a/61685169/143475

EDIT – it is possible to re-use the same browser instance for all tests and the Karate CI regression test does this, which is worth studying for ideas: https://stackoverflow.com/a/66762430/143475

Leave a Comment