Hello, I am using codeceptjs with webdriverio.
I am trying to achieve the same thing which codeception(php) provides with saveSession method.
this is my code:
async quicklyLogin() {
const I = this;
I.amOnPage('http://somepage.com');
if (this.cookie) {
I.setCookie(this.cookie);
I.refreshPage();
}
else {
I.fillField(loginUsername, 'name');
I.fillField(loginPassword, 'pass');
I.click(login.clickLogin);
this.cookie = await I.grabCookie('PHPSESSID');
}
}
The goal is to be able to use this quicklyLogin() method inside all other tests, so I skip the initial login step due to performance.
But the cookie is automatically deleted when the process ends.
Did you set the keepCookies to true?
keepCookies: (optional, default: false) - keep cookies between tests when restart set to false.
Yes. I set it in codecept.json, and also directly in the WebDriverIO defaults.. It keeps failing the same. Also I see that if in codecept.json I set "restart": false - should take care of the cookies, but still nothing is happening
Hi, I had a similar issue with puppeteer, when another Scenario starts it was cleaning the session, there is a setting to keep the session values: keepBrowserState => change to true
https://codecept.io/helpers/Puppeteer/
"helpers": {
"Puppeteer": {
"url": "http://url",
"show": true,
"restart": false,
"keepBrowserState": true,
"chrome": {
"args": [
"--no-sandbox"
]
}
}
},
Hope it helps you!
https://codecept.io/plugins/#autologin also helps!
Most helpful comment
Hi, I had a similar issue with puppeteer, when another Scenario starts it was cleaning the session, there is a setting to keep the session values:
keepBrowserState=> change to truehttps://codecept.io/helpers/Puppeteer/
Hope it helps you!