How to add bookmarks in Chromium/Chrome in automated fashion
How to add bookmarks in Chromium/Chrome in automated fashion
I am trying to test a Chrome extension that searches bookmarks. Puppeteer loads Chromium with a clean profile each time, which is great, but my bookmarks are empty.
I was hoping to find a way to load a bookmarks file, so I don't have to use the Chrome API to manually create a bookmark tree under a testing flag in my code.
1 Answer
1
You can load an existing user data directory with all of its data, including bookmarks and browser settings:
puppeteer.launch({
userDataDir: '/path/to/user-data-directory',
})
The profile must be from a Chrome/Chromium version close to the puppeteer's Chromium.
Also — in my experience path shouldn't contain spaces on Windows.
Some things to note: * Spaces worked for me, on macOS.
/Users/varr/Library/Application Support/Chromium
* The user data directory is not the profile directory in the user data directory (I made that mistake). chromium.googlesource.com/chromium/src/+/master/docs/… * Having two profiles in my user data directory caused two separate Chromium windows to open with puppeteer, so I deleted them all but one.– Eric Majerus
Jun 16 at 18:55
/Users/varr/Library/Application Support/Chromium
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
If you're going to use your rep to downvote, please comment a reason so I can correct the question.
– Eric Majerus
Jun 16 at 2:17