Can you help me with setCookie function. I use playwright driver, and when I try to call: I.setCookie({cookie}). I have an error:
browserContext.addCookies: Cookie should have a url or a domain/path pair
at Connection.sendMessageToServer (node_modules\playwright\lib\client\connection.js:69:15)
at Proxy. (node_modules\playwright\lib\client\channelOwner.js:44:61)
at path\node_modules\playwright\lib\client\browserContext.js:109:33
It would be useful to have a bit more context on this, but judging from your code and error it looks like you are trying to set a cookie before navigating to the website which is why you get that error.
Logically speaking to solve this you need to do the following steps:
first navigate to your website without any cookie set
set your cookies
refresh the page
You should now have your cookies setup and applied correctly.
You can do this as part of a helper and making use of hooks so that these actions are done before your actual test even starts.
Additionally, if this issue persists it might be something specific to Playwright and it will be worth opening a specific issue.
If you haven’t progressed too much you can always switch to something like WebDriverIO (WebDriver in CodeceptJS)