Add testing script
This commit is contained in:
parent
60addfb5d3
commit
c7fca02ad4
@ -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
1128
testing/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
testing/package.json
Normal file
15
testing/package.json
Normal 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
33
testing/script.js
Executable 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.");
|
||||
}
|
Loading…
Reference in New Issue
Block a user