const {Builder, By, Key, until} = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');

const options = new firefox.Options();
options.addArguments('-headless');

(async function example() {
	let driver = await new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
	try {
		await driver.get('http://www.google.com/ncr');
		await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
		await driver.wait(until.titleIs('webdriver - Google Search'), 10000);
		console.log('it worked!');
	} finally {
		await driver.quit();
	}
})();
