sambaiz / puppeteer-lambda-starter-kit

Starter Kit for running Headless-Chrome by Puppeteer on AWS Lambda.
MIT License
580 stars 82 forks source link

Node is either not visible or not an HTMLElement | page.click #33

Closed cirdes closed 5 years ago

cirdes commented 5 years ago

exports.run = async (browser) => { // implement here // this is sample const page = await browser.newPage(); await page.setViewport({width: 1024, height: 768});

page.on('dialog', async (dialog) => { console.log(dialog.message()); await dialog.dismiss(); });

await page.goto('http://efisco.sefaz.pe.gov.br/sfi_trb_gpf/PREmitirCertidaoNegativaNarrativaDebitoFiscal', {waitUntil: ['domcontentloaded', 'networkidle0']} ); await page.select('select#cdTipoDocumento', '2'); await page.select('select#cdOrgaoEmissor', '1'); await page.type('#nuDocumento', '17358877000151');

console.log('about to click'); await page.waitFor('#btt_emitir'); await Promise.all([ page.waitForNavigation(), page.click('#btt_emitir'), ]);

await page.close(); return 'done'; };


the code above executes using `npm run local` with success with headless mode on or off but on lambda I got this error on page.click function. 

2018-07-26 14:12:25.742 (-03:00) 0d39e55d-90f7-11e8-9154-f5bdacb2b61e about to click 2018-07-26 14:12:27.782 (-03:00) 0d39e55d-90f7-11e8-9154-f5bdacb2b61e {"errorMessage":"Node is either not visible or not an HTMLElement","errorType":"Error","stackTrace":["ElementHandle. (/var/task/node_modules/puppeteer/node6/lib/ElementHandle.js:190:13)","next (native)","step (/var/task/node_modules/puppeteer/node6/lib/ElementHandle.js:165:24)","Promise.resolve.then.value (/var/task/node_modules/puppeteer/node6/lib/ElementHandle.js:176:15)","process._tickDomainCallback (internal/process/next_tick.js:135:7)"]}



Any clues why I can run it locally but on lambda it's fail?

Thanks.
cirdes commented 5 years ago

Using not headless version solve the problem

RayeesMir commented 5 years ago

Try this

await page.evaluate(() => { document.querySelector("#btt_emitir").click(); });