最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to fill an input and select an option from the dropdown using Puppeteer? - Stack Overflow

programmeradmin4浏览0评论

I am working on a project with JavaScript and chose Puppeteer to perform web scraping on various websites. One of the websites I need to scrape is this one Mapas SII, from which I plan to obtain information using a property's ROL (a public identifier for properties in Chile). This information is publicly accessible and can be queried using other public data.

The problem is that I am unable to select or type in the "Comuna" (municipality) input field. I have tried different approaches, such as:

I tried filling out the form with these variations, but none of them seem to work. The 'Comuna' field is the only complex one because 'Manzana' and 'Predio' were easy to fill.

const selectorComuna = 'input[data-ng-model="nombreComuna"]';
await this.page.focus(selectorComuna);
await this.page.keyboard.type("MAI", { delay: 100 });
this.page.type(selectorComuna, "MAIPU", { delay: 100 });
await this.page.evaluate(() => {
            const comunaInput = document.querySelector('input[data-ng-model="nombreComuna"]');
            comunaInput.value = 'MAIPÚ'; 
            comunaInput.dispatchEvent(new Event('input', { bubbles: true })); 
        });
await this.page.locator(selectorComuna).fill(thisuna);

And none work. PD: Sorry for grammar errorsEnglish is not my first language.

发布评论

评论列表(0)

  1. 暂无评论