Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
buroli authored May 12, 2020
0 parents commit cb8a6ce
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
58 changes: 58 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const puppeteer = require('puppeteer');

// target only passport board but working with any others.
const baseUrl = 'https://audiovalley.atlassian.net/browse/PASSPORTV2'

// your jira credential
const cred = {
username : '[email protected]',
password: 'password'
};

// helper to login
const login = async (page, {username, password}) => {
await page.type('#username', username);
await page.click('#login-submit')
await page.waitFor(200);
await page.type('#password', password);
await page.click('#login-submit');
}

// helper to go to some url
const goToUrl = async (page, address, wait = 'networkidle0') => {
await page.goto(address, { waitUntil: wait });
}

// IIFE : execute function immediatly on load
/*
@param min - type Number => min value of ticket
@param max - type Number => max value of ticket
example : https://audiovalley.atlassian.net/browse/PASSPORTV2-2690
*/
(async (min, max) => {
const browser = await puppeteer.launch();
const page = await browser.newPage();

// overwrite default viewport of Chromium
await page.setViewport({ width: 1680, height: 836 });

// go to homepage
await goToUrl(page, baseUrl);
await page.waitFor(200);

// set credentials values
await login(page, cred);

// when window.COMPILED is true we can consider that jira is loaded
await page.waitForFunction('window.COMPILED === true');

// iterate over all pages and take screenshot
for(let i = min; i <= max; i++){
console.time('screen');
await goToUrl(page, `${baseUrl}-${i}`, 'networkidle2');
await page.screenshot({path: `${__dirname}/screen/screen_${i}.png`, fullPage: true});
console.timeEnd('screen');
}
// close browser
await browser.close();
})(2500, 2760);
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "screen",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"puppeteer": "^3.0.4"
}
}

0 comments on commit cb8a6ce

Please sign in to comment.