• Builds
  • latest 0.0.2 / 2018-02-13
  • Created 2017-11-02
  • Last modified 2018-09-12
  • grade 8


Example of loading a web page in headless Chrome using Selenium Webdriver.


To run the actor, send a HTTP POST request to:<YOUR_API_TOKEN>

The POST payload will be passed as input for the actor. For more information, read the docs.

Example input

Content type: application/json; charset=utf-8

{ "url": "" }

Source code

Based on the apify/actor-node-chrome Docker image (see docs).

const Apify = require('apify');
const { Capabilities, Builder, By, until, logging } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

// Enable logging if needed
// logging.installConsoleHandler();
// logging.getLogger('webdriver.http').setLevel(logging.Level.ALL);

Apify.main(async () => {
    console.log('Fetching input...');
    const input = await Apify.getValue('INPUT');
    if (!input || !input.url) throw new Error('Invalid input, must be a JSON object with the "url" field!');
    console.log('Launching Selenium WebDriver...');
    const webDriver = await Apify.launchWebDriver();

    console.log(`Opening ${input.url}...`);
    await webDriver.get(input.url);
    console.log('Getting the page title...');
    const pageTitle = await webDriver.executeScript(() => {
        return document.title;
    console.log(`Page title: ${pageTitle}`);
    console.log('Saving output...');
    await Apify.setValue('OUTPUT', {
        url: input.url,