Menu Close
    Convert your store into Multi Vendor Marketplace

    Disabling JavaScript Using Puppeteer

    JavaScript can be disabled using Puppeteer. We just need to obstruct requests and block loading if the type of id is “script” . Below is the code for disabling javascript from Puppeteer.

    const puppeteer = require('puppeteer');
    (async() => {
    const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.setRequestInterception(true);
      page.on('request', request => {
        if (request.resourceType() === 'script')
          request.abort();
        else
          request.continue();
      });
      await page.goto('https://webkul.com');
      await page.screenshot({path: 'webkul.png'});
    
      await browser.close();
      })();
    

    The webkul.png will look like below image in which javascript is disabled.

    webkul

    Thanks for reading this blog!

    Happy Testing 🙂

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    7 comments

  • Smith
    It gives useful information..
    • Priya Singh (Moderator)
      Thanks for your feedback:)
  • Parabjot
    Thnks for breafing, it’s helpful.
    • Garima Pathak (Moderator)
      Thanks for your feedback 🙂
  • Parabjot
    Thnks for breading, it’s helpful.
  • Kapil Kumar
    I was in need of clarifying this,Thank you for your solution .It was brief but sufficient
    • Garima Pathak (Moderator)
      Thanks for your feedback:)
  • Back to Top