Puppeteer is a Node.js library developed by Google that provides a high-level API to control
Unless we specify a different one executablePath
, Puppeteer launches the Chromium browser by default. It is designed to work seamlessly with Chromium, an open-source browser project that serves as the foundation for several browsers, including Google Chrome.
In this Answer, we will learn how to check for the browser version in Puppeteer.
The following is a syntax used to retrieve the browser version of the browser launched by the Puppeteer.
await browser.version();
The await
keyword in JavaScript is used to pause the execution of the script until the Promise returned by the following method is resolved.
Interested in learning more about the await
keyword? Check out the What is the await operator in JavaScript Answer for further details!
Execute the following code example by clicking the “Run” button below. You will see an instance of the Chrome browser launched within our widget in the “Output” tab and the version of that browser logged in the “Terminal” tab.
const puppeteer = require('puppeteer'); (async () => { console.log("Opening the browser in headful mode.....") // Launch a headful browser to verify the version const browser = await puppeteer.launch({ headless: false, args: ['--no-sandbox'] }); console.log("Browser has successfully been opened!") // Check the browser version browserVersion = await browser.version(); console.log("The browser version is: ", browserVersion); // Close the browser // await browser.close(); })();
We have launched the browser in headful mode, and the browser is opened in the “Output” tab. Verify the browser version retrieved with the browser.version()
method by comparing it with the browser version we manually checked from the browser, which is opened in the “Output” tab.
Unlock your potential: Puppeteer fundamentals series, all in one place!
To deepen your understanding of Puppeteer, explore our series of Answers below:
What is Puppeteer?
Learn about Puppeteer, a Node.js library that provides a high-level API for browser automation using headless Chrome or Chromium.
How to check for the browser version in Puppeteer
Discover how to retrieve the browser version using Puppeteer's browser.version()
method.
How to open the browser in headful mode with Puppeteer
Explore how to launch a visible browser instance by disabling the headless mode in Puppeteer.
How to get web page HTML with Puppeteer
Learn how to extract and manipulate a webpage’s HTML content using Puppeteer’s evaluate()
method.
What is the use of the setViewport method in Puppeteer?
Understand how setViewport()
customizes the browser’s viewport size for responsive testing and screenshots.
What is code coverage in Puppeteer?
Learn how to analyze unused JavaScript and CSS in web pages to optimize performance using Puppeteer’s coverage tool.
What is visual regression testing in Puppeteer?
Discover how Puppeteer can capture and compare screenshots to detect visual changes in web applications.
What is an accessibility test in Puppeteer?
Explore how Puppeteer, combined with accessibility tools like axe-core
, helps evaluate web accessibility compliance.
Free Resources