0

Selenium webdriver is not able to pull up the chrome dev tools. From what it looks like puppeteer could do this, but will it give me a way to save the interactive timeline report? Can puppeteer be run in a headfull mode? in an incognito tab? I saw the developers page but no specific examples

7
  • I don't have a full answer, so just adding a comment. I've used this to run puppeteer headfull. To run puppeteer in headfull way, set the option "puppeteer.launch({headless: false})". This is in the API docs: pptr.dev/… The docs also show how to run in incognito.
    – Lee Jensen
    Feb 4, 2020 at 20:56
  • Is there a reason behind this that prevents you to use performance testing tools like jmeter instead?
    – Moro
    Feb 5, 2020 at 6:20
  • @Moro Yes, I am looking at interactions from the time I click on the Mouse button for a login until the home page is rendered fully. Performance tab on Chrome Dev tools after recording has vertical green bars to show you mouse up mouse down etc, blue horizontal bars to show when the apis got started and ended, screenshots to confirm page has rendered etc. Can Jmeter do something like this? If so please let me know if there is a listener for this Feb 5, 2020 at 16:20
  • Any performance testing tool can measure page loading times and generate timelines, jmeter was just an example. I do not think Jmeter allows you to capture mouse events, however it can take Selenium scripts as input and in them you can code some mouse interactions. Again, I do not understand why would you need mouse interaction for performance testing, when you can simply record the http requests and use them in your script.
    – Moro
    Feb 6, 2020 at 9:15
  • 1
    Not sure about the details but I think Selenium 4 can work with dev tools.
    – Mate Mrše
    Mar 6, 2020 at 7:56

2 Answers 2

0

Yes, Puppeteer allows creation of "incognito" browser contexts with browser.createIncognitoBrowserContext() method. "Incognito" browser contexts don't write any browsing data to disk. and these sessions are known as Browser Contexts.

0

You can use Puppeteer to automate the performance tab record and stop, and save the interactive timeline report. Puppeteer is a Node.js library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol.

Here is an example code snippet for Puppeteer to start a new Chrome instance in headful mode, create a new page in an incognito tab, navigate to a web page, start recording the performance metrics, wait for a while, stop the recording and save the trace file.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({headless: false});
  const context = await browser.createIncognitoBrowserContext();
  const page = await context.newPage();
  await page.goto('https://www.example.com');
  await page.tracing.start({path: 'trace.json'});
  await page.waitForTimeout(5000);
  await page.tracing.stop();
  await browser.close();
})();

This code snippet starts a new Chrome instance in headful mode using puppeteer.launch({headless: false}), creates a new page in an incognito tab using browser.createIncognitoBrowserContext().newPage(), navigates to a web page using page.goto('https://www.example.com'), starts recording the performance metrics using page.tracing.start(), waits for 5 seconds using page.waitForTimeout(5000), stops the recording using page.tracing.stop() and saves the trace file to the current directory as trace.json.

You can modify this code to navigate to the web page you want to test and adjust the wait time accordingly. You can also use the page.tracing.start(options) method to specify additional trace options, such as the categories of events to record, and the page.tracing.stop() method to get the trace buffer and save it to a file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.