title: Electron testing - WebdriverIO switch between the devtools window and main app window
body: <p>We need to test <a href="http://electron.atom.io/" rel="nofollow noreferrer">Electron</a> App.
  We are using <a href="https://github.com/electron/spectron" rel="nofollow noreferrer">Spectron</a> which is using ChromeDriver and <a href="http://webdriver.io/api.html" rel="nofollow noreferrer">WebdriverIO</a> (Selenium 2.0 bindings for NodeJS).</p>
  
  <p><strong>Problem:</strong> Our application starts with open dev tools window than main application window is shown. Webdriver connects to dev tools window instead of the main window. We are unable to switch to main window.</p>
  
  <p>Example code:</p>
  
  <pre><code>var app = new Application({
      path: cfg.pathToElectron,
      args: [cfg.pathToSA]
  });
  
  app.start().then(function(){
      app.client // &lt;- this is dev tools window instead of main window
  
      // this closes the dev tools which is ok but we need to switch to main window
      app.client.close();
  
      // things like this doesn't help 
      app.client.execute('xxx.getCurrentWindow().closeDevTools()');
  });
  </code></pre>
  
  <p><strong>Any ideas how to switch from dev tools to main window?</strong></p>