samedi 7 mars 2020

How to launch all Karate features setting up which browser to use as an external maven variable

I was trying to find a way to launch all features in Karate testing through maven using an external variable to set up the browser (with a local webdriver or using a Selenium grid).

So something like:

mvn test -Dbrowser=chrome (or firefox, safari, etc)

or using a Selenium grid:

mvn test -Dbrowser=chrome (or firefox, safari, etc) -Dgrid="grid url"

With Cucumber and Java this was quite simple using a singleton for setting up a global webdriver that was then used in all tests. In this way I could run the tests with different local or remote webdrivers.

In Karate I tried different solution, the last was to:

  1. define the Karate config file a variable "browser"
  2. use the variable "browser" in a single feature "X" in which I set up only the Karate driver
  3. from all the other features with callonce to re-call the feature "X" for using that driver

but it didn't work and to be honest it doesn't seem to me to be the right approach. Probably being able to set the Karate driver from a Javascript function inside the features is the right way but I was not able to find a solution of that.

Another problem I found with karate is differentiating the behavior using a local or a remote webdriver as in the features files they're set in different ways.

So does anyone had my same needs and how can I solve it?

Many thanks

Francesco

PS It's my first question in Stackoverflow, so sorry I was not clear.

Aucun commentaire:

Enregistrer un commentaire