title: selenium-webdriver pass an array of functions as argument to executeScript
body: <pre><code>import webdriver from 'selenium-webdriver';
  
  const driver = new webdriver.Builder()
                .withCapabilities(webdriver.Capabilities.chrome())
                .build();
  
  driver.get('https://www.google.com');
  let foo = function(rules) {
    rules.forEach(rule =&gt; {
      rule();
    });
  }
  let bar = function() { return 'bar' };
  let baz = function() { return 'baz' };
  driver.executeScript(foo, [bar, baz]).then(function(result) {
    console.log(result);
  });
  
  driver.quit();
  </code></pre>
  
  <p>it errors out with </p>
  
  <pre><code>WebDriverError: unknown error: rule is not a function
  
  
  let foo = function(rules) {
    return rules;
    // rules.forEach(rule =&gt; {
    //   rule();
    // });
  }
  let bar = function() { return 'bar' };
  let baz = function() { return 'baz' };
  driver.executeScript(foo, [bar, baz]).then(function(result) {
    console.log(result); // refer the log pasted below
  });
  </code></pre>
  
  <p>Looks like the function are being serialized a <code>string</code></p>
  
  <pre><code>[ 'function bar() {\n  return \'bar\';\n}',
    'function baz() {\n  return \'baz\';\n}' ]
  </code></pre>
  
  <p>Any pointer on how to pass <code>array of functions as arguments</code> would be helpful.</p>