Nightwatch: Question about cookie behaviour

Created on 11 Jun 2014  Â·  6Comments  Â·  Source: nightwatchjs/nightwatch

I want to set a cookie (which is used to opt-out from tracking) before the url is opened which logs the following error. I'm using latest _Chrome_.

There was an error while executing the Selenium command
<unknown>: Failed to set the 'cookie' property on 'Document': Cookies are disabled inside 'data:' URLs.

You can see the full log with --verbose option here

When using Firefox the error is as simple as

There was an error while executing the Selenium command
You may only set cookies for the current domain

My question:
Is there any way to get around this ?

Test to reproduce:

module.exports = {

  'Set Cookie Before Open URL' : function (client) {

    var domain = 'nightwatchjs.org';
    var url = 'http://' + domain +'/';

    client
    .setCookie({
      name     : 'test_cookie',
      value    : 'test_value',
      path     : '/',
      domain   : domain,
    })
    .url(url)
    .waitForElementVisible('body', 1000)
    .end();
  }
};

Would you mind looking into this ?

regards
~david

needs more info selenium issue wontfix

Most helpful comment

The problem can be solved this way:

    .url('http://my-test-site.com') // not localhost!
    .setCookie({...})
    .url('http://my-test-site.com') // will open with necessary cookies

All 6 comments

Perhaps the mailing list is a better place for this question? I don't think
it's possible to do that but not completely sure.

On Wednesday, June 11, 2014, David Linse [email protected] wrote:

I want to set a cookie (which is used to opt-out from tracking) before the
url is opened which logs the following error. I'm using latest _Chrome_.

There was an error while executing the Selenium command
: Failed to set the 'cookie' property on 'Document': Cookies are disabled inside 'data:' URLs.

You can see the full log with --verbose option here
https://gist.github.com/davidlinse/f61b313d20ca00540a3d

When using Firefox the error is as simple as

You may only set cookies for the current domain

Is there any way to get around this ?

Test to reproduce:

module.exports = {

'Set Cookie Before Open URL' : function (client) {

var domain = 'nightwatchjs.org';
var url = 'http://' + domain +'/';

client
.setCookie({
  name     : 'test_cookie',
  value    : 'test_value',
  path     : '/',
  domain   : domain,
})
.url(url)
.waitForElementVisible('body', 1000)
.end();

}};

Would you mind looking into this ?

regards
~david

—
Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/177.

This is actually an issue (may i'll convert that) b/c afaik it's working when using _se-builder_ / _se-interpreter_ ..

The API call looks fine and the error is generated by selenium so there's a
high chance it won't work with any selenium binding. At least I don't see
what it can be done from nightwatch.

On Wednesday, June 11, 2014, David Linse [email protected] wrote:

This is actually an issue (may i'll convert that) b/c afaik it's working
when using _se-builder_ / _se-interpreter_ ..

—
Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/177#issuecomment-45804281
.

I am also facing the same issue. Is there any solution to the problem.

I'm closing this since I don't have enough information on how this could be fixed from nightwatch. Feel free to re-open if you have more details and any suggestions on how to fix it.

The problem can be solved this way:

    .url('http://my-test-site.com') // not localhost!
    .setCookie({...})
    .url('http://my-test-site.com') // will open with necessary cookies
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chaseconey picture chaseconey  Â·  4Comments

willli666 picture willli666  Â·  3Comments

MateuszJeziorski picture MateuszJeziorski  Â·  3Comments

davecranwell picture davecranwell  Â·  3Comments

betweenbrain picture betweenbrain  Â·  4Comments