Chromedriver
Chromedriver is probably the easiest way to get up and running locally. It's also conveniently free. This doesn't work well in headless environments (like CI servers), but is a great way to do a quick check of your tests in a local browser, where you can see everything that's going on.
Start by installing chromedriver:
npm install chromedriver --save-dev
Then you can test using code like:
import assert from 'assert';
import cabbie, {startChromedriver} from 'cabbie-async';
// Start the chromedriver server, this provides a local selenium server
// You must install chromedriver to use this.
startChromedriver();
async function runTest() {
// connect to chromedriver, adding {debug: true} makes cabbie log each method call.
const driver = cabbie('chromedriver', {debug: true});
try {
await driver.activeWindow.navigateTo('http://example.com');
const heading = await driver.activeWindow.getElement('h1');
assert.equal(
await heading.getText(),
'Example Domain',
);
} finally {
await driver.dispose();
}
}
runTest().catch(ex => {
console.error(ex.stack);
process.exit(1);
});