title: How to pass PhantomJS path to Selenium Grid
body: <p>I'm getting an error when trying to set up a phantomjs node on Selenium Grid (<a href="https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin" rel="nofollow">https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin</a>)</p>
  
  <p>I've set up the following custom json configuration:</p>
  
  <pre><code>{
    "capabilities": [
      {
        "browserName": "phantomjs",
        "phantomjs.binary.path": "/usr/bin/phantomjs",
        "platform": "LINUX",
        "maxInstances": 5
      }
    ],
    "configuration": {
      "nodeTimeout":120,
      "port":5555,
      "hubPort":4444,
      "hubHost":"localhost",
      "nodePolling":2000,
      "registerCycle":10000,
      "register":true,
      "cleanUpCycle":2000,
      "timeout":30000,
      "maxSession":1
    }
  }
  </code></pre>
  
  <p>But I get an error when I run webdriver against it:</p>
  
  <pre><code>WebDriverException: Message: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable; for more information, see https://github.com/ariya/phantomjs/wiki. The latest version can be downloaded from http://phantomjs.org/download.html
  Stacktrace:
      at com.google.common.base.Preconditions.checkState (Preconditions.java:199)
      at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS (PhantomJSDriverService.java:236)
      at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService (PhantomJSDriverService.java:181)
      at org.openqa.selenium.phantomjs.PhantomJSDriver.&lt;init&gt; (PhantomJSDriver.java:104)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance (Constructor.java:526)
      at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor (DefaultDriverProvider.java:103)
      at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance (DefaultDriverProvider.java:97)
      at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:60)
      at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222)
      at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:1)
      at java.util.concurrent.FutureTask.run (FutureTask.java:262)
      at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176)
      at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
      at java.lang.Thread.run (Thread.java:745)
  -------------------- &gt;&gt; begin captured logging &lt;&lt; --------------------
  selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session {"desiredCapabilities": {"browserName": "phantomjs"}}
  selenium.webdriver.remote.remote_connection: DEBUG: Finished Request
  </code></pre>
  
  <p>If I stop the node started by the plugin (and keep the plugin hub running), and manually run my own node as follows, it works fine:</p>
  
  <pre><code>java -jar selenium-server-standalone-2.53.0.jar -role webdriver 
      -browser browserName=phantomjs,platform=LINUX 
      -hub http://localhost:4444/grid/register
  </code></pre>
  
  <p>[edit] phantomjs is executable from the shell and lives at /usr/bin/phantomjs:</p>
  
  <pre><code>$ whereis phantomjs
  phantomjs: /usr/bin/phantomjs
  </code></pre>
  
  <p>I can't find a canonical description online of a phantomjs setup and this isn't one of the default browser options provided by the plugin.</p>
  
  <hr>
  
  <p>The problem with the above was the OS permissions on <code>/usr/bin/phantomjs</code>; I needed to do <code>chmod a+x</code> on it.</p>
  
  <hr>
  
  <p><strong>Cheekily adding this additional problem</strong></p>
  
  <p>This works (manually started by me):</p>
  
  <p><code>/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/bin/java -jar /var/lib/jenkins/selenium-server-standalone-2.53.0.jar -role webdriver -browser browserName=phantomjs,platform=LINUX -hub http://localhost:4444/grid/register</code></p>
  
  <p>This doesn't (the process started by the selenium plugin):</p>
  
  <p><code>/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/bin/java -cp /var/cache/jenkins/war/WEB-INF/lib/remoting-2.56.jar hudson.remoting.Launcher -cp /var/lib/jenkins/selenium-server-standalone-2.53.0.jar:/var/lib/jenkins/htmlunit-driver-standalone-2.20.jar -connectTo localhost:36322</code></p>
  
  <p>Error I'm getting when running the test:
  <code>PHPUnit_Extensions_Selenium2TestCase_WebDriverException: The process has not exited yet therefore no result is available</code></p>