'use strict';
const puppeteer = require( 'puppeteer' );
( async () =>
{
try
{
const browser = await puppeteer.launch( { 'headless' : false } );
const page = await browser.newPage();
await page.goto( 'some page' );
const table = await page.waitForSelector( 'body div table[summary]' );
const titles = await page.$$( 'body div table[summary] tr td[bgcolor]' );
console.log( titles.length );
const tableRows = await page.$$( 'body div table[summary] tr[nowrap]' );
console.log( tableRows.length );
// Declare variables before loop ...
const ciks = await page.$$( 'body div table[summary] tr td[bgcolor]' );
const titleName = await page.evaluate( button => button.innerText, button );
const formRows = await page.$$( 'body div table[summary] tr[nowrap]' );
const cell = await page.$( 'body div table[summary] tr[nowrap] td:nth-child(1)' );
let cik;
let button;
let formRow;
let tableCell;
for ( let i = 0; i < tableRows.length; i++ )
{
cik = ciks[i];
button = await cik.$( 'body div table[summary] tr td[bgcolor] a' );
console.log( titleName );
formRow = formRows[i];
tableCell = await formRow.$( 'body div table[summary] tr[nowrap] td' );
console.log( cell );
}
console.log( '\n' );
console.log( 'done' );
await browser.close();
}
catch ( e )
{
console.log( 'our error', e );
}
})();