First of all, it shouldn't shock you that a test tool starts from a blank state browser. Who would want the testing context to be polluted by previous browsing, settings, cookies, etc? Secondly, I find it a bit funny that you want to automate a task, but don't care to automate 3-5 more steps to execute a successful login.
If you have some extensive level of configurations that need to be added to your Chrome instance (cookies, local storage, extensions, users & passwords), then custom Chrome Profiles is what you're looking for.
- Identify where Chrome is storing the Default folder
You are basically trying to spawn Chrome with a specific set of configs. These are usually kept into the Default folder (path: /Users/YourUserHere/Library/Application Support/Google/Chrome/Default
).
!Note: This path might differ from OS to OS, so the recommended way to find out where Chrome is storing these configs on your device is by opening a new Chrome tab & typing chrome://version
. The setting we are looking for here is Profile Path.
Store the contents of your Default folder in your designated assets folder
Add the path to your custom Chrome configs via the --user-data-dir
Chromium CLI switch:
'goog:chromeOptions': {
// 'moz:firefoxOptions': {
args: [ '--no-sandbox',
'--disable-gpu',
'--start-fullscreen',
'--disable-notifications',
'--user-data-dir=/Path/To/Your/CustomConfigsFolder',
],
}
}
- Run your test with
browser.debug()
& check the configs have been successfully imported.
Note: I think I tackled this in a more generic sense on this answer. Check it out, maybe it further helps in setting this up.