Files
notifications-admin/backstop_data/engine_scripts/puppeteer/countFeatureLinks.js
alexjanousekGSA 5234706ae1 Added script
2024-09-23 13:08:29 -04:00

19 lines
618 B
JavaScript

module.exports = async (page, scenario) => {
await page.goto(scenario.url, { waitUntil: 'networkidle2' });
console.log('Page loaded.');
// Count the number of items in the side navigation and log their text
const navItems = await page.$$eval('nav ul li.usa-sidenav__item a', (items) =>
items.map((item) => item.textContent.trim())
);
console.log(`Found ${navItems.length} navigation items:`);
navItems.forEach((itemText, index) => {
console.log(`${index + 1}: ${itemText}`);
});
// Wait a moment for the logging to complete
await new Promise((resolve) => setTimeout(resolve, 1000));
};