sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
cd /tmp
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
In case there was an error
sudo apt-get -f install
sudo dpkg --configure -a
Test your installation and check the chrome version
google-chrome-stable -version
Spawn a new screen
screen
If screen is not yet installed on your droplet install it using apt-get
sudo apt-get install screen -y
Now you can run an instance of a headless chrome (make sure you're not running as root!)
google-chrome-stable --remote-debugging-port=9222 --disable-gpu --headless
To detach on the current screen type CTRL-A then D
Install the latest node.js version through PPA
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
Create a directory for your project and install chromeless
mkdir chromeless-project
cd chromeless-project
npm install chromeless
Open a file called app.js using your favorite text editor such as vi
nano app.js
Paste this code
const { Chromeless } = require('chromeless')
async function run() {
const chromeless = new Chromeless()
const screenshot = await chromeless
.goto('https://www.google.com')
.type('chromeless', 'input[name="q"]')
.press(13)
.wait('#resultStats')
.screenshot()
console.log(screenshot) // prints local file path or S3 url
await chromeless.end()
}
run().catch(console.error.bind(console))
Now run it
node app.js
You should get a screenshot of a google search for "chromeless"