Sources: Github,https://medium.com/
Sample project:
# Create project folder:
mkdir puppeteer_impl && cd puppeteer_implnpm init -ynpm install puppeteer -stouch app.js #Below is the content of app.js that can be put using any text editor.node app.jsapp.js
const puppeteer = require('puppeteer');const browser = await puppeteer.launch();const page = await browser.newPage();page.setViewport({ width: 1366, height: 768 }); #if not set defaults to 800X600 imagesawait page.goto('https://sites.google.com/site/mylearningsmyway/');await page.waitFor(2 * 1000);await page.screenshot({ path: 'test.jpg' });await page.click("#jot-ui-searchInput"); #clicks on text search fieldawait page.keyboard.type('puppeteer'); #Enters text in search fieldawait page.click("#sites-searchbox-select-button"); #clicks on search buttonawait page.waitFor(2 * 1000); #wait for search results await page.screenshot({ path: 'test1.jpg' });#create pdf using puppeteer
page.pdf({path:'somefile.pdf', landscape: true, format:'Letter'});Problem#1: Chromium installed but cannot be launched on target servers as they are non GUI servers.
Soln: use of docker. Ex- (Supporting libraries are installed in ubuntu container). DockerFile. Need to check with centos images.
How to get value of any element in html.