Posts

Showing posts with the label chromium

How can I set timeout option on every request in page.goto function

How can I set timeout option on every request in page.goto function I use puppeteer to scrab resources in a page. but one of the js request can not success because of connection timeout, and it will block the page.goto('url') function for a long time. I want to skip this js request and continue to request next. so i need to set timeout on every request, but not a total timeout option on page.goto function. Follow is my code test.js: const browser = await puppeteer.launch(); const page = await browser.newPage(); page.on('request', request => { console.log(request.url()) }) await page.goto(process.argv[2], {timeout: 10000}).then( () => { }, () => { console.log("timeout"); }); browser.close(); node test.js http://ipv6ready.wanwuyunlian.com:8080/ http://ipv6ready.wanwuyunlian.com:8080/ http://ipv6ready.wanwuyunlian.com:8080/js/bootstrap.min.js http://ipv6ready.wanwuyunlian.com:8080/js/echarts/echarts.min.js https://www.google-analytics.com/analyt...

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. 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 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 v...