title: Set user-agent with selenium-webdriver and phantomjs in nodejs
body: <p>I need to change the User-Agent of my PhantomJS browser that's driving selenium-webdriver.</p>
  
  <p>I've found <a href="http://simply-tutorial.com/blog/2014/07/10/selenium-webdriver-set-browsers-user-agent-and-proxy/" rel="noreferrer">methods to change the user agent in C#, Ruby and Java</a></p>
  
  <p>This is what I've tried:</p>
  
  <pre><code>var webdriver = require('selenium-webdriver');
  var useragent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0";
  
  var driver = new webdriver.Builder().
      withCapabilities(webdriver.Capabilities.phantomjs("phantomjs.page.settings.userAgent", useragent)).
      build();
  </code></pre>
  
  <p>The result on the web server still looks like this:
  <code>Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34</code></p>