How Can We Help?
Print

How to Use Puppeteer With Your NodeJS Discord Bot

Important! Puppeteer will only work from NodeJS version 18 onwards.

1. Within the Startup page on your panel, select your desired NodeJS version (you must select the Docker image from Cybrancee). This must also be for a NodeJS version that is 18 or later.

2. Add “puppeteer” to your Additional Node Packages field.

3. Reinstall your server via the Settings page.

4. Puppeteer is now installed and enabled. When you use Puppeteer, you will need always include the following parameters and includes within your code:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        args: ['--no-sandbox'],
  	});
  
  	//EXAMPLE USAGE
    const page = await browser.newPage();
    await page.goto('https://cybrancee.com');
    
    console.log(await page.title())
    
    
    await page.waitForSelector('xpath///*[@id="domain-search"]/span/input');
    await page.type('xpath///*[@id="domain-search"]/span/input', 'andreisawesome.com');
    
    await page.click('xpath///*[@id="domain-search"]/span/button[1]')
    
    await page.waitForNavigation();
    
    console.log(await page.title())
    
    await page.waitForSelector('xpath///*[@id="primaryLookupResult"]/div[2]/div/div[1]/i');
    
    let available = await page.waitForSelector('xpath///*[@id="primaryLookupResult"]/div[2]/div/div[2]/div[1]');
    
    const value = await available.evaluate(el => el.innerText);
    
    console.log(value)
	    
    await browser.close();
})();