I'm trying to take a screenshot of an element with selenium-webdriver, but UnsupportedOperationError was thrown?
<p>My current code looks like this.</p>

<pre><code>var webdriver = require('selenium-webdriver'),
until = webdriver.until,
By = webdriver.By,
fs = require('fs');

var driver = new webdriver.Builder()
  .forBrowser('chrome')
  .build();

driver.get('https://www.google.com/');

driver.findElement(By.css('#hplogo')).then((el) =&gt; {
  el.takeScreenshot().then((data) =&gt; {
    var base64Data = data.replace(/^data:image\/png;base64,/, "");
    fs.writeFile(__dirname + "/out.png", base64Data, 'base64', (err) =&gt; {
        if(err) console.log(err);
    });
  });
});
</code></pre>

<p>When I run it I get error message:</p>

<pre><code>/home/project/node_modules/selenium-webdriver/lib/promise.js:654
    throw error;
    ^

UnsupportedOperationError: unknown command: session/797c146086bc89ad245f76ce99302a48/element/0.9715665113180876-1/screenshot
    at WebDriverError (/home/project/node_modules/selenium-webdriver/error.js:26:26)
    at UnsupportedOperationError (/home/project/node_modules/selenium-webdriver/error.js:435:26)
    at Object.checkLegacyResponse (/home/project/node_modules/selenium-webdriver/error.js:578:13)
    at /home/project/node_modules/selenium-webdriver/lib/webdriver.js:360:15
    at Promise.invokeCallback_ (/home/project/node_modules/selenium-webdriver/lib/promise.js:1329:14)
    at TaskQueue.execute_ (/home/project/node_modules/selenium-webdriver/lib/promise.js:2790:14)
    at TaskQueue.executeNext_ (/home/project/node_modules/selenium-webdriver/lib/promise.js:2773:21)
    at /home/project/node_modules/selenium-webdriver/lib/promise.js:2652:27
    at /home/project/node_modules/selenium-webdriver/lib/promise.js:639:7
    at process._tickCallback (node.js:406:9)
</code></pre>

<p>I'm using selenium-webdriver version 2.52.0. Does anybody know what is going wrong?</p>