To navigate to a different page in Puppeteer, you can use the goto
method of the page
object. Here's an example of how you can use the goto
method to navigate to a different page:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
})();
goto
method to navigate to a different page. Specify the URL of the page you want to navigate to as the argument to the goto
method:await page.goto('https://www.example.com');
goto
method to navigate to a different page by clicking on a link or button on the current page. First, use the click
method to click on the link or button, and then use the waitForNavigation
method to wait for the navigation to complete:await page.click('a#linkId');
await page.waitForNavigation();
By following these steps, you can navigate to a different page in Puppeteer.