-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
1 changed file
with
39 additions
and
32 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 |
---|---|---|
@@ -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); | ||
} | ||
|
||
|
||
})(); |