Puppeteer

How can I check that an element is visible with Puppeteer and pure JavaScript?

妖精的绣舞 提交于 2020-01-22 11:58:50
问题 I wish to check that a DOM element is visible with Puppeteer and pure JavaScript (not jQuery), how can I do this? By visible I mean that the element is displayed through CSS, and not hidden (f.ex. by display: none ). For example, I can determine whether my element #menu is not hidden via CSS rule display: none , in the following way: const isNotHidden = await page.$eval('#menu', (elem) => { return elem.style.display !== 'none' }) How can I determine in general though if the element is hidden

How can I check that an element is visible with Puppeteer and pure JavaScript?

两盒软妹~` 提交于 2020-01-22 11:58:08
问题 I wish to check that a DOM element is visible with Puppeteer and pure JavaScript (not jQuery), how can I do this? By visible I mean that the element is displayed through CSS, and not hidden (f.ex. by display: none ). For example, I can determine whether my element #menu is not hidden via CSS rule display: none , in the following way: const isNotHidden = await page.$eval('#menu', (elem) => { return elem.style.display !== 'none' }) How can I determine in general though if the element is hidden

Puppeteer find array elements in page and then click

岁酱吖の 提交于 2020-01-17 01:14:08
问题 Hello I have site that url are rendered by javascript. I want to find all script tags in my site, then math script src and return only valid ones. Next find parent of script and finally click on link. This is what i have: const scripts = await page.$$('script').then(scripts => { return scripts.map(script => { if(script.src.indexOf('aaa')>0){ return script } }); }); scripts.forEach(script => { let link = script.parentElement.querySelector('a'); link.click(); }); My problem is that i have

How to locate the source of my memory leak?

走远了吗. 提交于 2020-01-16 12:00:14
问题 I've got a Puppeteer project where I'm trying to record and analyze the structure of some online forms. I expect to see a list of each form input 's name attribute values printed to the console. But instead, I get the following error. (node:4014) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 Symbol(Events.FrameManager.FrameDetached) listeners added to [FrameManager]. Use emitter.setMaxListeners() to increase limit How can I locate the source of the memory leak or

NodeJS HTTP Request Queue

帅比萌擦擦* 提交于 2020-01-15 11:29:05
问题 I've created scraper using puppeteer & node js (express). The idea is when server received http request then my apps will start scraping the page. The problem is if my apps receive multiple http request at one time. Scraping process will start over and over again until no http request hit. How do i start only one http request and queue the other request until the first scraping process finish ? Currently, i've tried node-request-queue with codes below but no lucks. var express = require(

page.goto freezes on Google Cloud Functions for some websites

我怕爱的太早我们不能终老 提交于 2020-01-15 09:57:13
问题 I am using: Puppeteer version: 1.13.0 Platform / OS version: Google Cloud Node.js version: 8 await.page.goto("https://somewebsite.com") freezes when I deploy it on Google Cloud functions. I receive timeout error. Navigation Timeout Exceeded const browser = await puppeteer.launch({ headless: true, ignoreHTTPSErrors: true, args: [ '--disable-gpu', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--no-first-run', '--no-sandbox', '--no-zygote', '--single-process', // <- this one doesn't

How to obtain a pdf embedded in page through puppeteer?

二次信任 提交于 2020-01-15 08:49:27
问题 I am trying to obtain a pdf copy of a page whose structure is like so: <body style="background-color: rgb(38,38,38); height: 100%; width: 100%; overflow: hidden; margin: 0"> <embed width="100%" height="100%" name="plugin" id="plugin" src="https://www.thesourceurl.com" type="application/pdf" internalinstanceid="7" title=""> </body> I tried getting it with page.pdf but I got a blank pdf with "Couldn't load plugin" written in the middle. 回答1: This seems to be a bug in Puppeteer. It definitely

How to scroll inside a div with Puppeteer?

醉酒当歌 提交于 2020-01-14 19:17:04
问题 I want to use Puppeteer to scroll inside a div that has a scrollbar, but where the overall window doesn't have a scrollbar. Let's take for example, the following URL: https://www.google.com/maps/place/DO+%26+CO+Restaurant+Stephansplatz/@48.2082385,16.3693837,17z/data=!4m7!3m6!1s0x476d079f2c500731:0xed65abfb2c337243!8m2!3d48.2082385!4d16.3715725!9m1!1b1 You can see in the left hand side there are reviews, and the whole section has a scrollbar. A quick inspect element shows that the whole thing

How to clear an item value in puppeteer

て烟熏妆下的殇ゞ 提交于 2020-01-14 12:17:45
问题 I have an iFrame with several items and i want to update a record. const frame = await page.frames()[1]; const P1_CUSTOM_NAME = await frame.$('#P1_CUSTOM_NAME'); await P1_CUSTOM_NAME.type('MyFavoritCustomer', {delay: 20}); This will not overwrite the field P1_CUSTOM_NAME . Unfortunately it appends the value 'MyFavoritCustomer' . Any suggestions how i can clear an item value? 回答1: Try a triple click to focus and select all. const frame = await page.frames()[1]; const P1_CUSTOM_NAME = await

How to clear an item value in puppeteer

自闭症网瘾萝莉.ら 提交于 2020-01-14 12:13:06
问题 I have an iFrame with several items and i want to update a record. const frame = await page.frames()[1]; const P1_CUSTOM_NAME = await frame.$('#P1_CUSTOM_NAME'); await P1_CUSTOM_NAME.type('MyFavoritCustomer', {delay: 20}); This will not overwrite the field P1_CUSTOM_NAME . Unfortunately it appends the value 'MyFavoritCustomer' . Any suggestions how i can clear an item value? 回答1: Try a triple click to focus and select all. const frame = await page.frames()[1]; const P1_CUSTOM_NAME = await