Monday 29 May 2017

Adding cookies with Selenium Webdriver

I have the following sequence of Selenium code, written with Node.js:

   it('tests cookies', t => {
      driver.manage().getCookies().then(function (cookies) {
        console.log('all cookies => ', cookies);
      });
      driver.manage().addCookie({name:'foo', value: 'bar'});
      driver.manage().getCookies().then(function (cookies) {
        console.log('all cookies => ', cookies);
      });
      driver.manage().deleteCookie('foo');
      return driver.manage().getCookies().then(function (cookies) {
        console.log('all cookies => ', cookies);
      });
    });

and I get this output:

all cookies =>  []
all cookies =>  []
all cookies =>  []

anybody know why the addCookie functionality wouldn't work? I am not sure I understand why this wouldn't yield some cookies in the cookie jar.



via Alexander Mills

No comments:

Post a Comment