Skip to content

Commit

Permalink
update puppeteer test
Browse files Browse the repository at this point in the history
  • Loading branch information
pfreitag authored Oct 2, 2023
1 parent 8b81cd1 commit 1b4b682
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions tests/puppeteer/test.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
const puppeteer = require('puppeteer');
const process = require('node:process');


(async() => {

const browser = await puppeteer.launch();

const page = await browser.newPage();
await page.goto('http://127.0.0.1:8855/', {waitUntil: 'load'});
console.log(page.url());

await page.type('#x', '5');
await page.type('#y', '3');

await page.click('#addButton');

setTimeout(async()=> {
const answer = await page.$eval('#z', el => { return el.value } );

await page.screenshot({path: 'screenshot.png'});
if (answer == "8") {
console.log("Value Was 8");
await browser.close();
process.exit(0);
} else {
console.log("Value was not 8, it was: " + answer);
await browser.close();
process.exit(1);
}
console.log('starting puppeteer script');
try {
const browser = await puppeteer.launch();

const page = await browser.newPage();
await page.goto('http://127.0.0.1:8855/', {waitUntil: 'load'});
console.log(page.url());

await page.type('#x', '5');
await page.type('#y', '3');

await page.click('#addButton');

setTimeout(async()=> {
const answer = await page.$eval('#z', el => { return el.value } );

await page.screenshot({path: 'screenshot.png'});
if (answer == "8") {
console.log("Value Was 8");
await browser.close();
process.exit(0);
} else {
console.log("Value was not 8, it was: " + answer);
await browser.close();
process.exit(1);
}

}, 500);

}, 200);

setTimeout(()=> {
console.log("15 Second Timeout Reached");
browser.close();
process.exit(1);
}, 15000);
setTimeout(()=> {
console.log("15 Second Timeout Reached");
browser.close();
process.exit(1);
}, 15000);

} catch (err) {
console.log('Error running puppeteer');
console.error(err);
process.exit(1);
}


})();

0 comments on commit 1b4b682

Please sign in to comment.