Skip to content

Instantly share code, notes, and snippets.

@JohannesFischer
Last active February 19, 2018 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesFischer/facbd0c1c063e349fdb3837951966834 to your computer and use it in GitHub Desktop.
Save JohannesFischer/facbd0c1c063e349fdb3837951966834 to your computer and use it in GitHub Desktop.
Selenium Node Tests
const webdriver = require('selenium-webdriver');
const { By, promise, until } = webdriver;
const firefox = require('selenium-webdriver/firefox');
const binary = new firefox.Binary(firefox.Channel.NIGHTLY);
binary.addArguments('-headless');
const capabilities = {
acceptInsecureCerts: true
};
// const width = 1024;
// const height = 768;
const timeout = 3000;
async function getLinks() {
const driver = new webdriver.Builder()
.withCapabilities(capabilities)
.forBrowser('firefox')
.setFirefoxOptions(new firefox.Options().setBinary(binary))
.build();
try {
const url = 'https://global.rakuten.com/en/event/';
await driver.get(url);
const eventLinks = await driver.findElements(By.css('div.event-items > a'));
promise.map(eventLinks, e => e.getAttribute('href'))
.then(function(href) {
console.log(href);
});
} finally {
await driver.quit();
}
}
getLinks();
{
"name": "selenium-node",
"version": "0.0.1",
"description": "Automated testing setup with Selenium and Firefox running on Node",
"main": "index.js",
"scripts": {
"test": "No test command available."
},
"repository": {
"type": "git",
"url": "git+https://github.com/N/A.git"
},
"keywords": [
"selenium",
"firefox",
"automated-testing",
"node"
],
"author": "Johannes Fischer",
"license": "ISC",
"bugs": {
"url": "https://github.com/N/A/issues"
},
"homepage": "https://github.com/N/A#readme",
"dependencies": {
"selenium-webdriver": "^3.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment