Created
June 27, 2016 20:41
-
-
Save remarkablemark/fd967e6403f763b588f21c775f1bf4e9 to your computer and use it in GitHub Desktop.
Setting a cookie with WebDriverJS with parallel flows.
This file contains hidden or 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
| 'use strict'; | |
| /** | |
| * Module dependencies. | |
| */ | |
| const webdriver = require('selenium-webdriver'); | |
| /** | |
| * Run clients in parallel and set cookie. | |
| * https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/example/parallel_flows.js | |
| */ | |
| for (let index = 0; index < 5; index++) { | |
| const flow = new webdriver.promise.ControlFlow(); | |
| flow.on('uncaughtException', (error) => { | |
| console.error(index, 'uncaughtException in flow', error); | |
| }); | |
| const builder = new webdriver.Builder(); | |
| const driver = builder.forBrowser('phantomjs') | |
| .setControlFlow(flow) | |
| .build(); | |
| driver.get(`https://httpbin.org/cookies/set?index=${index}`); | |
| driver.getTitle().then((title) => { | |
| console.log(index, title); | |
| }); | |
| driver.manage().getCookies().then((cookies) => { | |
| console.log(index, cookies) | |
| }); | |
| driver.quit(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment