title: How to launch all Karate features setting up which browser to use as an external maven variable
body: <p>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). </p>
  
  <p>So something like:</p>
  
  <pre><code>mvn test -Dbrowser=chrome (or firefox, safari, etc)
  </code></pre>
  
  <p>or using a Selenium grid:</p>
  
  <pre><code>mvn test -Dbrowser=chrome (or firefox, safari, etc) -Dgrid="grid url"
  </code></pre>
  
  <p>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. </p>
  
  <p>In Karate I tried different solution, the last was to:</p>
  
  <ol>
  <li>define the Karate config file a variable "browser"</li>
  <li>use the variable "browser" in a single feature "X" in which I set up only the Karate driver</li>
  <li>from all the other features with callonce to re-call the feature "X" for using that driver</li>
  </ol>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>So does anyone had my same needs and how can I solve it?</p>