gpt4 book ai didi

angularjs - Browser.manage().addCookie() 返回错误丢失 'name'

转载 作者:行者123 更新时间:2023-12-01 10:26:35 45 4
gpt4 key购买 nike

当我尝试在 Protractor 中设置 cookie 时,我收到以下错误消息:

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



enter image description here

我使用以下不同的代码在 Protractor 中设置 cookie。但他们都没有工作。

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

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

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

我正在使用 Protractor 版本 5.2 运行代码。

谁能帮我吗?提前致谢。

最佳答案

我得到了我的问题的解决方案。下面的代码对我有用。

(browser.manage() as any).addCookie({ name: 'test', value: 'test', domain: 'localhost' });

关于angularjs - Browser.manage().addCookie() 返回错误丢失 'name',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47217572/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com