Reputation: 1866
Is it possible to run a WebdriverIO test case with Google Chrome, without creating a "private Chrome window" (no cache or cookies).
I want to start the Chrome browser I want to use the cookies and cache from Chrome, not a completely default state
Scenario: I am logging into our back-end on Chrome, which sets a token that I use on my localhost. When I run a test through Webdriverio, it doesn't have the token and I have to go through the login process once more.
So, in the terminal, if I run open http://localhost:3001
, Chrome will open the application without needing to log in again.
!Note: I don't want to go through a login process on my tests... I just want to use the session token stored in Chrome after I login manually.
Upvotes: 2
Views: 4343
Reputation: 4112
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.
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',
],
}
}
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.
Upvotes: 3