title: selenium js webdriver - attach to active session
body: <p>I am using Node.js with <code>selenium-webdriver</code> package to run my tests.<br>
  every time a test start, the web driver starts a new session and open a new window.<br>
  I am trying to get the session Id and use it later using <code>getSession()</code> 
  (<a href="https://selenium.googlecode.com/git/docs/api/javascript/source/lib/webdriver/builder.js.src.html" rel="nofollow">doc referance link</a> )  </p>
  
  <pre><code>var webdriver = require('selenium-webdriver');
  var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
  
  var server = new SeleniumServer('./seleniumServer/selenium-server-standalone-2.43.1.jar', {
      port: 4444
  });
  server.start();
  
  var driver = new webdriver.Builder()
          .usingServer(server.address())
          .withCapabilities(webdriver.Capabilities.firefox())
          .build();
  
  console.log(driver.getSession());
  </code></pre>
  
  <p>But this causes an exception:</p>
  
  <pre><code>getSession();
  ^
  TypeError: Object [object Object] has no method 'getSession'
      at Object.&lt;anonymous&gt; (\testing\demo_1.js:14:3)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Function.Module.runMain (module.js:497:10)
      at startup (node.js:119:16)
      at node.js:906:3
  </code></pre>
  
  <p>Can anyone tell me what's wrong with it and how I get and set the selenium session id?<br>
  Most importantly, how do I use the <code>sessionId</code> for attaching to an opened browser session?</p>