WebDriverError: unable to set cookie javascript - Stack Overflow

I'm trying to set a cookie in Protractor and its not allowing me.Here is the error: WebDriverError

I'm trying to set a cookie in Protractor and its not allowing me.

Here is the error:

    WebDriverError: unable to set cookie
  (Session info: chrome=63.0.3239.132)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
    at WebDriverError (e:\node_modules\selenium-webdriver\lib\error.js:27:5)
    at Object.checkLegacyResponse (e:\node_modules\selenium-webdriver\lib\error.js:505:15)
    at parseHttpResponse (e:\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (e:\node_modules\selenium-webdriver\lib\http.js:440:13)
    at process._tickCallback (internal/process/next_tick.js:109:7)

Here is the test code that responsible for setting the cookies

beforeEach(function() {
        //Enable Angular synchonization
        protractor_1.browser.waitForAngularEnabled(true);
        //Disable animations
        protractor_1.browser.manage().addCookie({ name: 'disableAnimations', value: 'true' }, '/', '127.0.0.1');
    });

Why is my test code not able to set the cookie?

I'm trying to set a cookie in Protractor and its not allowing me.

Here is the error:

    WebDriverError: unable to set cookie
  (Session info: chrome=63.0.3239.132)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
    at WebDriverError (e:\node_modules\selenium-webdriver\lib\error.js:27:5)
    at Object.checkLegacyResponse (e:\node_modules\selenium-webdriver\lib\error.js:505:15)
    at parseHttpResponse (e:\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (e:\node_modules\selenium-webdriver\lib\http.js:440:13)
    at process._tickCallback (internal/process/next_tick.js:109:7)

Here is the test code that responsible for setting the cookies

beforeEach(function() {
        //Enable Angular synchonization
        protractor_1.browser.waitForAngularEnabled(true);
        //Disable animations
        protractor_1.browser.manage().addCookie({ name: 'disableAnimations', value: 'true' }, '/', '127.0.0.1');
    });

Why is my test code not able to set the cookie?

Share Improve this question edited Feb 3, 2018 at 12:22 grizzthedj 7,51517 gold badges46 silver badges65 bronze badges asked Feb 1, 2018 at 11:59 Tamer HussienTamer Hussien 8371 gold badge10 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

If thats the full code - i can only suggest that you must first open the page for which domain you want to add cookies, like:

beforeEach(function () {
    protractor_1.browser.waitForAngularEnabled(true);
    browser.get('http://127.0.0.1:8080') // set your url here
    //Disable animations
    protractor_1.browser.manage().addCookie({
        name: 'disableAnimations',
        value: 'true'
    }, '/', '127.0.0.1');
});

Selenium can only set cookies for already opened domain page

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745316640a4622249.html

相关推荐

  • WebDriverError: unable to set cookie javascript - Stack Overflow

    I'm trying to set a cookie in Protractor and its not allowing me.Here is the error: WebDriverError

    12小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信