Last active
February 19, 2018 00:15
-
-
Save JohannesFischer/facbd0c1c063e349fdb3837951966834 to your computer and use it in GitHub Desktop.
Selenium Node Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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