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)
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.
I got solution of my problem. Below code worked for me.
(browser.manage() as any).addCookie({ name: 'test', value: 'test', domain: 'localhost' });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With