title: Running Selenium webdriver-manager from Gradle
body: <p>I am trying to start Selenium from Gradle in order to run Protractor tests.</p>
  
  <p>Here is my Gradle script:</p>
  
  <pre><code>//main task to run protractor tests
  task uiTests &lt;&lt; {
      println "Starting protractor tests"
  }
  
  //start Selenium server
  task startSelenium &lt;&lt; {
      println "Starting Selenium..."
      ant.exec(executable: '/bin/bash', spawn: true) {
          arg(value:'webdriver-manager')
          arg(value:'start')
      }
  }
  
  //run protractor
  task runProtractor(type: Exec) {
      commandLine 'protractor', 'bignibou-client/protractor.conf.js'
  }
  
  //start selenium, then run protractor
  uiTests.dependsOn([startSelenium, runProtractor])
  </code></pre>
  
  <p>However, the output seems to indicate that the Selenium process has not being started:</p>
  
  <pre><code> :runProtractor
      Using the selenium server at http://localhost:4444/wd/hub
      [launcher] Running 1 instances of WebDriver
  
  /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172
        callback(new Error(message));
                 ^
  Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
      at ClientRequest.&lt;anonymous&gt; (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172:16)
      at emitOne (events.js:77:13)
      at ClientRequest.emit (events.js:169:7)
      at Socket.socketErrorListener (_http_client.js:259:9)
      at emitOne (events.js:77:13)
      at Socket.emit (events.js:169:7)
      at emitErrorNT (net.js:1250:8)
      at doNTCallback2 (node.js:429:9)
      at process._tickCallback (node.js:343:17)
  From: Task: WebDriver.createSession()
      at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
      at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
      at [object Object].Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
      at [object Object].DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
      at [object Object].Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:182:37)
      at /usr/local/lib/node_modules/protractor/lib/runner.js:263:21
      at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
      at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
      at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
      at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:525:49
  [launcher] Process exited with error code 1
  :runProtractor FAILED
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':runProtractor'.
  &gt; Process 'command 'protractor'' finished with non-zero exit value 1
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  </code></pre>
  
  <p>Can anyone please provide informed tips and guidance?</p>