I'm using the selenium-webdriver npm module for Node.JS, however I am having trouble writing the cookies to the console. I used the example code from the NPM page (Under usage)
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
console.log(driver.manage().getCookies());
driver.quit();
Now, I would expect console.log to write the dictionary I've seen referenced in other questions, however I get the following output:
ManagedPromise {
flow_:
ControlFlow {
propagateUnhandledRejections_: true,
activeQueue_:
TaskQueue {
name_: 'TaskQueue::5',
flow_: [Circular],
tasks_: [Object],
interrupts_: null,
pending_: null,
state_: 'new',
unhandledRejections_: Set {} },
taskQueues_: Set { [Object] },
shutdownTask_: null,
hold_:
Timeout {
_called: false,
_idleTimeout: 2147483647,
_idlePrev: [Object],
_idleNext: [Object],
_idleStart: 231,
_onTimeout: [Function: wrapper],
_repeat: [Function] } },
stack_: { [Task: WebDriver.manage().getCookies()] name: 'Task' },
parent_: null,
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null }
I get no errors in my console, but I'm not getting the cookies I expected either. I'm using the latest version of node, v5.9.1, and the latest version of selenium-webdriver. For some reason the console.log code is called before selenium's instance of Firefox even starts. How would I go about fixing this?