Puppeteer

Hash-based navigation with puppeteer

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 23:55:42
问题 I am trying to navigate to the url which contains # in the url which is returning Error: Navigation Timeout Exceeded: 30000ms exceeded it('should go to new link', async function(){ await page.goto('https://example.com/#/abc', {waitUntil: 'networkidle2'}) await page.waitForNavigation() await page.waitFor(15000); }) Original code expects a path to a tag having value as #/abc await page.waitForSelector('a tag selector') await page.click('a tag selector') await page.waitForNavigation() await page

How do I create a CSV file from all of these elements?

强颜欢笑 提交于 2019-12-24 23:17:31
问题 I am trying to get the text from both of these sections and turn it into a CSV list from puppeteer: item number: (Item 1055688) price: ( $16.59) here's what I tried but it doesn't seem to work to find the SKU for example: let elements = await.self.page.$$('div[class="row item-row"]'); for (let element of elements) { let sku = await element.$eval(('div[class="body-copy custom-body- copy"]'), node => node.innerText.trim()); } Here is the code I am trying to extract the data from: <div class=

Polymer Starter Kit with Node, Express, and Puppeteer

半城伤御伤魂 提交于 2019-12-24 23:02:31
问题 Okay, I'm a newbie to all this so any help greatly appreciated. I've managed to use Node and Express to serve up Polymer Starter Kit (PSK) website from the Polymer build directory from a file I created in the home directory (server.js): // Node.js notation for importing packages var express = require('express'); // Spin up a server var app = express(); // Serve static files from the main build directory app.use(express.static(__dirname + '/build/es5-bundled')); // Render index.html on the

Node.js puppeteer - Downloading/Accessing a xml file and process the content

血红的双手。 提交于 2019-12-24 22:00:04
问题 Node.js puppeteer - How do I download, access and process a xml file and the content in puppeteer? When clicking on a link like: await page.evaluate(() => { document.querySelector('#datagrid > div > a:nth-child(2)').click(); }); ... I can download a xml file looking like this: XML file: <table> <row> <column>Titel01</column> <column>Titel02</column> <column>Titel03</column> <column>Titel04</column> <column>Titel05</column> <column>Titel06</column> <column>Titel07</column> <column>Titel08<

How to wait for event triggered page reloads with Puppeteer?

杀马特。学长 韩版系。学妹 提交于 2019-12-24 18:57:37
问题 I'm trying safely handle the behavior of a page which uses an in-browser event on a select element to trigger a page reload (POST). The URL is the same but the page reloads with the same HTML and the only difference is the sort order of content in a table. I tried several methods but somehow none are reliable, how can I achieve something like this: try { await page.select('select[name=sort]', 'size'); await page.waitForNextPageReload(); await page.waitForSelector('select[name=sort]'); } catch

How to avoid 'frame got detached' error async validation or redirect with Puppeteer?

折月煮酒 提交于 2019-12-24 07:58:25
问题 A previous answer pointed me into the direction, on how to catch an async validation error or redirect. But in my scenario an iframe comes into play and it's keeping me busy, all day. Some pointers into the right direction would be really helpfull, since I can't get it right, eventhough the error states clearly what goes wrong. The scenario's: An input is left empty. A button is clicked inside an iframe and a validation error is returned from an async request An input has a value. A button is

How to copy text from browser clipboard using Puppeteer in nodejs

≯℡__Kan透↙ 提交于 2019-12-24 06:21:12
问题 Is a there a way where I can copy content from browser clipboard using Puppeteer in nodejs. I am trying to copy content post the page is rendered. This is being achieved by the bellow code but unable to get the content. await page.keyboard.down('ControlLeft'); await page.keyboard.press('KeyA'); await page.keyboard.up('ControlLeft'); await page.keyboard.down('ControlLeft'); await page.keyboard.press('KeyC'); await page.keyboard.up('ControlLeft'); 回答1: Copy from input box You can evaluate the

Karma tests using a Docker image of Chrome

寵の児 提交于 2019-12-24 04:41:14
问题 For tests on CI server I want to use an image of Chrome instead of PhantomJS. I can do this with and without puppeteer but both require me to install chrome-stable package on the server. Thus I want a more lightweight method hence the use of the docker image. For Karma, according to the docs, I must specify a script for the browser if i want to use a custom browser. Also Karma will pass 1 argument to this script, the url. For this requirement I also pulled the browserless docker image

How to listen to postMessage messages in Puppeteer?

半腔热情 提交于 2019-12-24 01:43:32
问题 https://github.com/GoogleChrome/puppeteer/blob/master/examples/custom-event.js shows how to define your own event, but doesn't show how to transmit event data back to the code outside Puppeteer. For example, if I want to read event data the page postMessage s in code using Puppeteer to launch the page, how would you do that? Related: https://github.com/GoogleChrome/puppeteer/issues/2366 回答1: I just bumped into the same problem and below is something that worked for me. Using the same example

How can I obtain the original encoded response size when intercepting requests with Puppeteer?

核能气质少年 提交于 2019-12-24 01:01:30
问题 I'm using this code to log the encoded response size when loading a page in Chrome: const puppeteer = require("puppeteer"); (async function() { const browser = await puppeteer.launch(); const page = await browser.newPage(); page._client.on("Network.loadingFinished", data => { console.log("finished", { encodedDataLength: data.encodedDataLength }); }); // await page.setRequestInterception(true); // page.on("request", async request => { // request.continue(); // }); await page.goto("http:/