Add testing script

This commit is contained in:
Tyler Perkins 2023-12-04 21:41:51 -05:00
parent 60addfb5d3
commit c7fca02ad4
Signed by: tyler
GPG Key ID: 03B27509E17EFDC8
7 changed files with 1179 additions and 0 deletions

View File

@ -13,6 +13,9 @@ repos:
- id: check-added-large-files
- id: check-case-conflict
- id: pretty-format-json
args:
- "--autofix"
- "--no-sort-keys"
- id: check-symlinks
- id: detect-private-key
- id: sort-simple-yaml

1128
testing/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

15
testing/package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "testing",
"version": "1.0.0",
"description": "",
"main": "script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"puppeteer": "^21.5.2"
}
}

33
testing/script.js Executable file
View File

@ -0,0 +1,33 @@
const puppeteer = require('puppeteer');
async function takeScreenshot(url) {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
// Use the URL from the command line argument
await page.goto(url);
const captchaSelector = '#captcha';
if (await page.$(captchaSelector) !== null) {
await page.evaluate(selector => {
const element = document.querySelector(selector);
element.scrollIntoView();
}, captchaSelector);
await page.screenshot({ path: 'screenshot.png' });
} else {
console.log('CAPTCHA element not found');
}
await browser.close();
}
// Get URL from command line arguments
const url = process.argv[2];
if (url) {
takeScreenshot(url);
} else {
console.log("Please provide a URL as a command line argument.");
}