title: How do I limit simultaneous Selenium browsers being run by Jenkins?
body: <p>I have a Jenkins project that runs more than a hundred Cucumber feature files. Each test scenario uses Selenium because I need to test the UI of my website. The problem is that Jenkins tries to run them almost all at once hence I get an explosion of Selenium Google Chrome browsers trying to pop up all at once. This leads to my machine running out of memory and only a few Selenium browsers being responsive.</p>
  <p>Is there a way for me to limit the number of Selenium browsers being active at one time? It could be on Jenkins or in Selenium but I'd rather stay away from Selenium Grid.</p>
  <p>I've already tried looking into limiting it in Jenkins but it seems like you can only just limit the number of parallel builds. My problem is that I only have one build and it's executing all tests almost all at once.</p>
  <p>As for Selenium Grid, the command that is used in the build step of Jenkins explicitly says NOT to use Selenium Grid.</p>
  <p>Under Jenkins, for the Execute Windows batch command:</p>
  <pre><code>cd folderLocation
  mvnw clean verify -Dgui.feature.tags=@test -Dbrowser=chrome -Dforked.jvm.count=3 -Duse.selenium.grid=false
  </code></pre>
  <p>With this command, the test runners are created to specify all scenarios to be run and the location of the results JSON files.</p>
  <p>The codebase for Selenium, Java, and Maven are copied from another machine. When you run the Jenkins project manually, they have a limit of active Selenium browsers at a time on that machine. However on the new machine, we re-did the setup of Jenkins and if you run the build, it will try to start all the Selenium browsers all at once and most browsers ended up being unresponsive. After a while, it will end up in an error memory dump.</p>
  <p>I repeat, is there a way for me to limit the number of Selenium browsers open?</p>