Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser.manage().addCookie() returns error missing 'name'

When I am trying to set cookies in protractor, I am getting below error message:

Failed: invalid argument: missing 'name'
(Session info:chrome=61.0.3163.100)

enter image description here

I have used below different codes to set cookie in protractor. But none of them is working.

Case 1:

browser.get('http://localhost:8080');
browser.driver.manage().addCookie('test', 'test');

Case 2:

browser.get('http://localhost:8080');
protractor.browser.manage().addCookie({ 'name': 'test', 'value': 'test', 'path': '/', 'domain': 'localhost' });

Case 3:

browser.get('http://localhost:8080');
browser.manage().addCookie('test', 'test', '/', 'localhost');

I am running code with protractor version 5.2.

Can anyone help me out? Thanks in advance.

like image 226
Pratik Gadoya Avatar asked Mar 08 '23 15:03

Pratik Gadoya


1 Answers

I got solution of my problem. Below code worked for me.

(browser.manage() as any).addCookie({ name: 'test', value: 'test', domain: 'localhost' });
like image 146
Pratik Gadoya Avatar answered Mar 25 '23 01:03

Pratik Gadoya