title: Selenium & webdriver.io how to use executeScript?
body: <p>I'm trying to test a simple form using Selenium, WebDriver.io &amp; Node.js (with Mocha). So I have something like this:</p>
  
  <pre><code>var webdriverio = require('webdriverio');
  var expect = require('expect');
  
  describe('Test form', function(){
      beforeEach(function() {
          browser.url('/');
      });
  
      it('should save object', function() {
          expect(browser.executeScript('return window.data;')).to.be([]);
      });
  
      afterEach(function() {
          if (this.currentTest.state !== "passed") {
              browser.saveScreenshot();
          }
      });
  });
  </code></pre>
  
  <p>My <code>wdio.conf.js</code>:</p>
  
  <pre><code>var selenium = require('selenium-standalone');
  var seleniumServer;
  
  exports.config = {
      host: '127.0.0.1',
      port: 4444,
  
      specs: [
          'test/*.spec.js'
      ],
  
      capabilities: [{
          browserName: 'chrome'
      }],
  
      baseUrl: 'http://localhost:8080',
      framework: 'mocha',
  
      mochaOpts: {
          ui: 'bdd'
      },
  
      onPrepare: function() {
          return new Promise((resolve, reject) =&gt; {
              selenium.start((err, process) =&gt; {
                  if(err) {
                      return reject(err);
                  }
                  seleniumServer = process;
                  resolve(process);
              })
          });
      },
  
      onComplete: function() {
          seleniumServer.kill();
      }
  };
  </code></pre>
  
  <p>But in console I have: <code>browser.executeScript is not a function</code>. What is the right way to execute script in browser context using these tools?</p>