<commit_before>const CWD = __dirname;
const path = require('path');
const Ssm = require('selenium-screen-master');
const ssm = new Ssm();

const jar = require('selenium-server-standalone-jar');
jar.path = path.join(CWD, 'selenium-server-standalone-3.0.1.jar');

const SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;

const server = new SeleniumServer(jar.path, {
    port: 4444
});

const SERVER_URL = 'http://statlex.github.io/';
const WEB_DRIVER_SERVER_URL = 'http://localhost:4444/wd/hub';

let WebDriver = require('selenium-webdriver');
let byCss = WebDriver.By.css;
let driver;

server.start()
    .then(() => {

        driver = new WebDriver
            .Builder()
            .usingServer(WEB_DRIVER_SERVER_URL)
            .withCapabilities({'browserName': 'chrome'})
            .build();

        driver.get(SERVER_URL);
        ssm.setDriver(driver);

// USE like this

        return ssm
            .takeScreenshotOfSelector('#ancient-empire-strike-back')
            .then(image => {
                // image base64
                console.log(image);
            });

// OR like this

        return ssm
            .takeScreenshotOfElement(driver.findElement(byCss('#ancient-empire-strike-back')))
            .then(image => console.log(image));

// OR like this

        return ssm
            .takeScreenshotOfArea(80, 200, 500, 300)
            .then(image => console.log(image));

    })
    .then(() => driver.quit())
    .then(() => server.stop());<commit_msg>update example<commit_after>const Ssm = require('selenium-screen-master');
const ssm = new Ssm();

const SERVER_URL = 'http://statlex.github.io/';
const WEB_DRIVER_SERVER_URL = 'http://localhost:4444/wd/hub';

let WebDriver = require('selenium-webdriver');
let byCss = WebDriver.By.css;
let driver = new WebDriver
    .Builder()
    .usingServer(WEB_DRIVER_SERVER_URL)
    .withCapabilities({'browserName': 'chrome'})
    .build();

driver.get(SERVER_URL);

ssm.setDriver(driver);

ssm
    .takeScreenshotOfSelector('#ancient-empire-strike-back')
    .then(image => {
        // image base64
        console.log(image);
    });

// OR

ssm
    .takeScreenshotOfElement(driver.findElement(byCss('#ancient-empire-strike-back')))
    .then(image => console.log(image));

// OR

ssm
    .takeScreenshotOfArea(80, 200, 500, 300)
    .then(image => console.log(image));
{'fraction_non_alphanumeric': 0.1545608108108108, 'fraction_numerical': 0.01731418918918919, 'mean_word_length': 2.9286898839137647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4409235', 'n_tokens_mistral': 833, 'n_tokens_neox': 779, 'n_words': 136}