I have a code snippet that currently looks like this:
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) => {
el.takeScreenshot().then((data) => {
var base64Data = data.replace(/^data:image\/png;base64,/, "");
fs.writeFile(__dirname + "/out.png", base64Data, 'base64', (err) => {
if(err) console.log(err);
});
});
});
Upon running this code, I encounter the following error message:
/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)
The version of selenium-webdriver I am using is 2.52.0. Can anyone provide insight into what may be causing this issue?