-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cb8a6ce
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |