Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Emissão Nota Fiscal Prefeitura do Recife - Puppeteer (wip)
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: false,
});
const page = await browser.newPage();
const userData = {
login: 'x',
password: 'y',
doc_number_for: '05278901462',
person_name: "Djalma Araujo de Andrade",
total: 500,
description: `TRADERTAX
I - "DOCUMENTO EMITIDO POR ME OU EPP OPTANTE PELO SIMPLES NACIONAL";
II - "NÃO GERA DIREITO A CRÉDITO FISCAL DE ICMS, DE ISS E DE IPI".`
}
const run = async (browser, page) => {
await page.goto(`https://nfse.recife.pe.gov.br/senhaweb/login.aspx`);
// Login
await page.type('input[name="ctl00$cphCabMenu$tbCpfCnpj"]', userData.login);
await page.type('input[name="ctl00$cphCabMenu$tbSenha"]', userData.password);
await page.waitFor(5000)
await page.click('input[name="ctl00$cphCabMenu$btEntrar"]');
await page.waitFor('a[href="nota.aspx"]');
await page.click('a[href="nota.aspx"]');
// Select simples nacional — CNPJ
await page.waitFor('input[name="ctl00$cphCabMenu$tbCPFCNPJTomador"]');
await page.type('input[name="ctl00$cphCabMenu$tbCPFCNPJTomador"]', userData.doc_number_for);
// Select simples nacional — Tributado no Recife
await page.click('#ctl00_cphCabMenu_rbNoMunicipio');
// Go
await page.click('input[name="ctl00$cphCabMenu$btAvancar"');
// Doc number
await page.waitFor('#ctl00_cphCabMenu_tbCPFCNPJ');
await page.type('#ctl00_cphCabMenu_tbCPFCNPJ', userData.doc_number_for);
await page.select('#ctl00_cphCabMenu_ctrlServicos_ddlServicos', "0107");
await page.waitFor('#ctl00_cphCabMenu_ctrlServicos_ddlAtividades');
await page.select('#ctl00_cphCabMenu_ctrlServicos_ddlAtividades', "6209100");
await page.waitFor('#ctl00_cphCabMenu_tbDiscriminacao');
await page.type('#ctl00_cphCabMenu_tbDiscriminacao', userData.description);
await page.waitFor('#ctl00_cphCabMenu_tbValor');
await page.type('#ctl00_cphCabMenu_tbValor', userData.total.toString());
await page.waitFor('#ctl00_cphCabMenu_ctrlServicos_tbAliquota');
await page.type('#ctl00_cphCabMenu_ctrlServicos_tbAliquota', '5');
await page.waitFor('#ctl00_cphCabMenu_rblISSRetido_1');
await page.click('#ctl00_cphCabMenu_rblISSRetido_1');
// await page.waitFor('#ctl00_cphCabMenu_btEmitir');
// await page.click('#ctl00_cphCabMenu_btEmitir');
// await browser.close();
}
run(browser, page, userData);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.