Sources: Github,https://medium.com/
Sample project:
# Create project folder:
mkdir puppeteer_impl && cd puppeteer_impl
npm init -y
npm install puppeteer -s
touch app.js #Below is the content of app.js that can be put using any text editor.
node app.js
app.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 images
await 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 field
await page.keyboard.type('puppeteer'); #Enters text in search field
await page.click("#sites-searchbox-select-button"); #clicks on search button
await 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.