Skip to content

Commit

Permalink
add screenshots to hello.js
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Dec 30, 2024
1 parent 78ace5f commit 674273d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions scripts/pit/its/hello.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
const { chromium, webkit } = require('playwright');
const screenshots = "screenshots.out"

let headless = false, host = 'localhost', port = '8080', hub = false;
let headless = false, host = 'localhost', port = '8080', mode = 'prod', name;
process.argv.forEach(a => {
if (/^--headless/.test(a)) {
headless = true;
} else if (/^--ip=/.test(a)) {
ip = a.split('=')[1];
} else if (/^--port=/.test(a)) {
port = a.split('=')[1];
} else if (/^--mode=/.test(a)) {
mode = a.split('=')[1];
} else if (/^--name=/.test(a)) {
name = a.split('=')[1];
}
});

let sscount = 0;
async function takeScreenshot(page, name) {
const path = `${screenshots}/${++sscount}-${name}-${mode}.png`;
await page.screenshot({ path });
log(`Screenshot taken: ${path}\n`);
}

(async () => {
const browser = await chromium.launch({
headless: headless,
Expand All @@ -27,6 +37,7 @@ process.argv.forEach(a => {
// Go to http://localhost:8080/
await page.goto(`http://${host}:${port}/`);

await takeScreenshot(page, 'initial-view');
// Click input[type="text"]
await page.locator('input[type="text"]').click({timeout:60000});

Expand All @@ -35,6 +46,8 @@ process.argv.forEach(a => {

// Click text=Say hello
await page.locator('vaadin-button').click();
await takeScreenshot(page, 'button-clicked');


// Look for the text, sometimes rendered in an alert, sometimes in the dom
let m;
Expand Down

0 comments on commit 674273d

Please sign in to comment.