title: Can I/how can I translate a Selenium webdriver test script from node.js over to phantomjs - ghostdriver?
body: <p>I recently began working with Selenium and to make life easier to start I was using node to run my scripts so that I could visually monitor the tests. My challenge now is to convert it so that it can be run as a headless test. Unfortunately, most of the resources that I have come across only address using phantomjs and ghostdriver with Java or Python. My boss wants me to run the test through phantomjs without Java or Python. Eventually these tests will be run remotely through a Linux VM on a server without a GUI. Currently I am testing using Mac OS X 10.8 and still have many bridges to cross in order to get to my goal.</p>
  
  <p>My most important question firstly, is it possible to run a script from phantomjs through a port without the use of Java or Python? I have spent hours poring through as many resources as I could come across and I've come up with no solution.</p>
  
  <p>If so, how can I properly initialize the test to run headless? Here is how I scripted the start of my functioning test. I want to properly switch the capabilities from firefox to phantomjs and be able to run it headless using the appropriate port. The rest of the test navigates to a specific site, logs in through a widget, then does further navigation to the area which I will build further tests on which to manipulate after I get this working.</p>
  
  <pre><code>var webdriver = require('selenium-webdriver'),
  SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
  
  var server = new SeleniumServer("Path/selenium-server-standalone-2.39.0.jar", {
  port: 8910
  });
  
  server.start();
  
  var driver = new webdriver.Builder().
  usingServer(server.address()).
  withCapabilities(webdriver.Capabilities.firefox()).
  build();
  </code></pre>
  
  <p>The test works perfectly, but I am new to this so there might be something foolish that I am overlooking. Please let me know what adjustments to make so that it will run headless through phantom. When I attempt to use node to run the script after switching capabilities to phantomjs it produces </p>
  
  <pre><code>"/Selenium/node_modules/selenium-webdriver/phantomjs.js:22
  LogLevel = webdriver.logging.LevelName,
                              ^
  TypeError: Cannot read property 'LevelName' of undefined
   at Object.&lt;anonymous&gt; (/Selenium/node_modules/selenium-webdriver/phantomjs.js:22:33)
  </code></pre>
  
  <p>That's a read only file that I can't adjust, any attempts that I made to define "LogLevel" or "LevelName" to the appropriate corresponding value (DEBUG, etc.) were fruitless.</p>
  
  <p>And if I run it through phantomjs itself I get -</p>
  
  <pre><code>"Error: Cannot find module 'path'
  
   phantomjs://bootstrap.js:289
   phantomjs://bootstrap.js:254 in require"
  
  (It also lists module 'http') -- (and various undefined function errors)
  </code></pre>
  
  <p>I feel that with that instance I didn't properly organize where the files for Selenium, phantomjs, and ghostdriver should go in order to play nice. I also removed the server setup portion and instead ran this first, then the script separately.</p>
  
  <pre><code>phantomjs --webdriver=8910 
  </code></pre>
  
  <p>But it yielded the same result. All of my research to fix these issues turned up instructions for Java and Python but not Javascript by itself. Rather than chase through many rabbit holes I figured it wise to consult better minds.</p>
  
  <p>If you know better than I do and that it is fruitless to attempt this without Java or Python, please let me know. If you know where the issue lies within my script and could propose a fix please let me know. I hope that I have properly described the nature of my issue and if you need more information I will do my best to provide it to you.</p>
  
  <p>This is my second week working with Javascript so if you believe I am making a noob error you very well may be correct. Please, keep in mind that the script works through node with selenium webdriver.</p>
  
  <p>Many thanks for your time!!!
  ~Isaac</p>