profile
viewpoint
Vse Mozhet Byt vsemozhetbyt Kyiv, Ukraine

lingvoboard/nodereplacer 2

Tool for creating dictionaries

lingvoboard/AsyncLinesReader 1

Node.js script for reading text file line by line.

vsemozhetbyt/gls_sd_conv 1

Скрипт, конвертирующий исходные файлы .gls в словари StarDict и обратно.

vsemozhetbyt/vsemozhetbyt.github.io 1

Some vsemozhetbyt's varia

vsemozhetbyt/AsyncLinesReader 0

Node.js script for reading text file line by line.

vsemozhetbyt/node 0

Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:

vsemozhetbyt/puppeteer 0

Headless Chrome Node API

issue commentpuppeteer/puppeteer

Getting freform text from a div

puppeteer can transfer two types of data between Node.js and browser context: serializable data (i.e. data that is supported by JSON.stringify()/JSON.parse()) and JavaScript object ids (including DOM elements) — JSHandle and ElementHandle. Later ones have a bit more complicated API (see JSHandle and ElementHandle methods or methods that mention them).

page.evaluate() can only transfer serializable data, and instead of un-serializable data, it returns undefined or empty objects. DOM elements are non-serializable as they contain circular references and methods.

So if you just need some text or element attributes, try to do most of the processing in the browser context and return just serializable data.

const result = await page.evaluate(() => Array.from(
  document.querySelectorAll('.u-vr4x'),
  element => element.innerText
);
console.log(result);
ballfam

comment created time in 2 days

issue commentnodejs/help

Need help converting code to callback function or async/await

For starters, I can suggest these two ways, with a callback or async/await. If you need some more explanation, please ask)

  1. With a callback.
// module.js

function getChanID(chanType, callback) {
  db.getConnection((err, con) => {
    con.query(`SELECT * FROM channels WHERE type = '${chanType}'`, (err, rows) => {
      if (err) throw err;

      const chanID = rows[0].id;
      con.release();
      callback(chanID);
    });
  });
}

module.exports = {
  getChanID,
};
// main.js

const { getChanID } = require('./module.js');

const chanType = 'foo';

getChanID(chanType, processChanID);

function processChanID(chanID) {
  console.log(chanID);
  // Other code using chanID.
}
  1. With async/await.
// module.js

function getChanID(chanType) {
  return new Promise((resolve, reject) => {
    db.getConnection((err, con) => {
      con.query(`SELECT * FROM channels WHERE type = '${chanType}'`, (err, rows) => {
        if (err) {
          reject(err);
        } else {
          const chanID = rows[0].id;
          con.release();
          resolve(chanID);
        }
      });
    });
  });
}

module.exports = {
  getChanID,
};
// main.js

const { getChanID } = require('./module.js');

(async function main() {
  try {
    const chanType = 'foo';

    const chanID = await getChanID(chanType);

    console.log(chanID);
    // Other code using chanID.
  } catch (err) {
    console.error(err);
  }
})();
Syntthetix

comment created time in 3 days

issue closednodejs/node-v8

Last versions lack some binaries

Last full build: https://nodejs.org/download/v8-canary/v15.0.0-v8-canary202006192e28363093/

Deficient builds: https://nodejs.org/download/v8-canary/v15.0.0-v8-canary202006254d76a1d646/ https://nodejs.org/download/v8-canary/v15.0.0-v8-canary2020062643c97a74f2/

closed time in 4 days

vsemozhetbyt

issue commentnodejs/node-v8

Last versions lack some binaries

Closing for now as we have no binaries at all for the last 10 days.

vsemozhetbyt

comment created time in 4 days

issue commentrauschma/impatient-js

Chapter: Single objects

25.6.9.4 A polyfill for Object.fromEntries()

The npm package object.fromentries is a polyfill for Object.entries()

Object.entries() -> Object.fromEntries()?

rauschma

comment created time in 6 days

issue commentrauschma/impatient-js

Chapter: Single objects

25.5.1.1 Handling defaults via nullish coalescing

Description mentions '(no street)' value, but code use '(no name)'.

rauschma

comment created time in 6 days

issue commentpuppeteer/puppeteer

How to get click event handler name

There is a quirk mentioned here: you need objectGroup set to get the handler. Here are some ways to get the name:

const html = `
  <!doctype html>
  <html>
    <head>
      <meta charset='UTF-8'>
      <title>Test</title>
      <script>
        function main() {
          document.body.addEventListener('click', logClick);
        }

        function logClick() {
          console.log('click');
        }
      </script>
    </head>
    <body onload='main();'>Text.</body>
  </html>`;

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch();
    const [page] = await browser.pages();

    await page.goto(`data:text/html,${html}`);

    const cdp = await page.target().createCDPSession();

    const nodeObject = (await cdp.send('Runtime.evaluate', {
      expression: "document.querySelector('body')",
      objectGroup: 'foobar',
    })).result;

    const listenerObject = (await cdp.send('DOMDebugger.getEventListeners', {
      objectId: nodeObject.objectId,
    })).listeners[0].handler;

    const listenerName1 = (await cdp.send('Runtime.callFunctionOn', {
      functionDeclaration: 'function() { return this.name; }',
      objectId: listenerObject.objectId,
      returnByValue: true,
    })).result.value;

    const listenerName2 = (await cdp.send('Runtime.getProperties', {
      objectId: listenerObject.objectId,
      ownProperties: true,
    })).result.find(property => property.name === 'name').value.value;

    await cdp.send('Runtime.releaseObject', { objectId: listenerObject.objectId });
    await cdp.send('Runtime.releaseObject', { objectId: nodeObject.objectId });
    await cdp.send('Runtime.releaseObjectGroup', { objectGroup: 'foobar' });

    console.log(listenerName1);
    console.log(listenerName2);

    await browser.close();
  } catch (err) {
    console.error(err);
  }
})();

Output:

logClick
logClick
pradeepgill007

comment created time in 12 days

Pull request review commentpuppeteer/puppeteer

feat: page.waitForTimeout

 const puppeteer = require('puppeteer'); })(); ``` +#### frame.waitForTimeout(milliseconds)+- `milliseconds` <[number]> The number of milliseconds to wait for.+- returns: <[Promise]> Promise which resolves after the timeout has completed.++Pauses script execution for the given number of seconds before continuing:++```js+const puppeteer = require('puppeteer');++(async () => {+  const browser = await puppeteer.launch();+  const page = await browser.newPage();+  let currentURL;

Ditto)

jackfranklin

comment created time in 13 days

starteddmnd/dedent

started time in 14 days

issue commentrauschma/impatient-js

Chapter: Strings

Misformatting in 18.7.4 String.prototype: finding and matching - .indexOf(searchString: string, minIndex=0): number [ES1]:

s

rauschma

comment created time in 15 days

issue commentpuppeteer/puppeteer

xpath string(.)

If .innerText or .textContent in browser context do not suffice, you can try to collect text nodes in the browser context with xPath (document.evaluate()) and transfer them as texts.

laosandegudai

comment created time in 16 days

issue commentpuppeteer/puppeteer

xpath string(.)

If you need text nodes of an Element, you need const title=await titleEle[0].$x('./text()'), but I am not sure if a text node is a valid puppeteer Element handler.

laosandegudai

comment created time in 16 days

startedWisdom/Awesome-Unicode

started time in 17 days

issue commentpuppeteer/puppeteer

How do I change Puppeteer's focus to a second tab? 0

Something like this:

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch({ headless: false, defaultViewport: null });
    const [page] = await browser.pages();

    await page.goto('https://example.org/');

    const link = await page.$('a[href]');

    const [target] = await Promise.all([
      new Promise(resolve => browser.once('targetcreated', resolve)),
      link.click({ button: 'middle' }),
    ]);

    const newPage = await target.page();
    await newPage.bringToFront();
  } catch (err) {
    console.error(err);
  }
})();
sfelice777

comment created time in 19 days

issue commentpuppeteer/puppeteer

How do I change Puppeteer's focus to a second tab? 0

You can listen to 'targetcreated' event and then use page.bringToFront().

sfelice777

comment created time in 19 days

issue commentpuppeteer/puppeteer

waitForFunction has no DOM references for: document, window

Also, can it be that this code (window.screenCaptureReady = true;) is executed in an iframe or a web worker?

crh3675

comment created time in a month

issue commentpuppeteer/puppeteer

waitForFunction has no DOM references for: document, window

I cannot reproduce with this simplified code. Can you?

'use strict';

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch(); // { headless: false, defaultViewport: null, args: ['--lang=en'] }
    const [page] = await browser.pages();

    await page.goto('https://example.org/');

    await page.evaluate(() => {
      window.screenCaptureReady = false;
      setTimeout(() => { window.screenCaptureReady = true; }, 5000);
    });

    console.log(`window.screenCaptureReady is ${
      await page.evaluate(() => window.screenCaptureReady)
    }. Waiting...`);

    await page.waitForFunction('window.screenCaptureReady');

    console.log(`window.screenCaptureReady is ${
      await page.evaluate(() => window.screenCaptureReady)
    }.`);

    await browser.close();
  } catch (err) {
    console.error(err);
  }
})();

Output:

window.screenCaptureReady is false. Waiting...
window.screenCaptureReady is true.

Can there be any error in "some loading stuff here and then" preventing the execution of window.screenCaptureReady = true;?

crh3675

comment created time in a month

issue commentpuppeteer/puppeteer

Unexcpected behaviour after entering data

It seems the innerTexts of the elements you set are not sent to the server. Instead, you need to change the values of the form elements which are sent to the server. For example, check the document.querySelectorAll('[name^="checkin_"]') and document.querySelectorAll('[name^="checkout_"]') elements and their values set after the calendar widget manipulation.

photocherkaoui

comment created time in a month

startedescaya/escaya

started time in a month

issue commentpuppeteer/puppeteer

Error: No node found for selector

And maybe use '.OabDMe .cXrdqd .Y2Zypf' instead of '.OabDMe cXrdqd Y2Zypf'.

photocherkaoui

comment created time in a month

issue commentpuppeteer/puppeteer

Error: No node found for selector

Navigation timeout of 30000 ms exceeded

Then maybe browser behavior is different in headless mode. Try to use puppeteer.launch({ headless: false}); and check the element in the console.

For a class named: DarkModeToggle__Layout-cfa1ot-0 exXfxw , how can I point to it?

You can try '[class="DarkModeToggle__Layout-cfa1ot-0 exXfxw"]'.

photocherkaoui

comment created time in a month

issue commentpuppeteer/puppeteer

Error: No node found for selector

Maybe await page.waitFor(1000); does not suffice. Try to use await page.waitForSelector('.OabDMe cXrdqd Y2Zypf'); instead.

photocherkaoui

comment created time in a month

startedpyppeteer/pyppeteer

started time in a month

issue commentpuppeteer/puppeteer

How to Disable images in Puppeteer?

@MohammadJamali https://github.com/puppeteer/puppeteer/blob/main/examples/block-images.js https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagesetrequestinterceptionvalue

TheOne1006

comment created time in a month

issue commentrauschma/impatient-js

Chapter: Syntax

// Import whole module as namespace object `path`
import * as path from 'path';

Is 'path' is a bit surprising here (as only module file paths were mentioned before)?

rauschma

comment created time in a month

issue openednodejs/node-v8

Last versions lack some binaries

Last full build: https://nodejs.org/download/v8-canary/v15.0.0-v8-canary202006192e28363093/

Deficient builds: https://nodejs.org/download/v8-canary/v15.0.0-v8-canary202006254d76a1d646/ https://nodejs.org/download/v8-canary/v15.0.0-v8-canary2020062643c97a74f2/

created time in a month

issue commentpuppeteer/puppeteer

page.evaluate doesn't run the function, throws a TypeError

There are two issue here.

  1. In await page.evaluate((addUserMessage) => addUserMessage("Hurray!")); the addUserMessage is undefined as you do not add the function as a parameter. This should be: await page.evaluate((addUserMessage) => addUserMessage("Hurray!"), addUserMessage);.

  2. Even with this syntax this function transferring is impossible: per docs, you can only transfer serializable values from Node.js (puppeteer) context into browser context, and functions are not serializable. If react-chat-widget can be imported in the web page context, you need to import it there first and then just call inside page.evaluate().

See page.evaluate() in docs for details.

naser-baig-au4

comment created time in a month

delete branch vsemozhetbyt/node

delete branch : doc-timers

delete time in a month

PR opened nodejs/node

doc: add missing backticks in timers.md
Checklist
  • [x] make -j4 test (UNIX), or vcbuild test (Windows) passes
  • [x] documentation is changed or added
  • [x] commit message follows commit guidelines
+2 -2

0 comment

1 changed file

pr created time in a month

create barnchvsemozhetbyt/node

branch : doc-timers

created branch time in a month

fork vsemozhetbyt/node

Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:

https://nodejs.org/

fork in a month

issue commentpuppeteer/puppeteer

Unable to click on hyperlink via puppeteer

Also, value1 in const [value1] = await page.$x() is already an ElementHandle, it is not an array, so you need not [0] index in the next line. Just try await value1.click().

sayom88

comment created time in a month

startedNikolaiT/Crawling-Infrastructure

started time in 2 months

startedNikolaiT/GoogleScraper

started time in 2 months

issue commentpuppeteer/puppeteer

Unable to access input fields for nike login

It seems the id is generated randomly. Try another selector, for example:

await page.type('[name="emailAddress"]', 'myEmail@outlook.com', { delay: 110 });
bulldogs55

comment created time in 2 months

issue commentpuppeteer/puppeteer

Unable to pass `ReadableStream` object to `page.exposeFunction(name, puppeteerFunction)`

Maybe as with the page.evaluate(), transferred arguments and returned values should be serializable. If so, the doc needs to be clarified.

aksharj

comment created time in 2 months

issue commentpuppeteer/puppeteer

Unable to get all iframes in the page

Strange difference between headless and headful session:

const puppeteer = require('puppeteer');

(async function main1() {
  try {
    let browser = await puppeteer.launch({ defaultViewport: null });
    let [page] = await browser.pages();

    await page.goto('https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe');

    console.log(await page.evaluate(() => document.querySelectorAll('iframe').length));
    console.log((await page.frames()).length);

    await browser.close();

    browser = await puppeteer.launch({ headless: false, defaultViewport: null });
    [page] = await browser.pages();

    await page.goto('https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe');

    console.log(await page.evaluate(() => document.querySelectorAll('iframe').length));
    console.log((await page.frames()).length);

    await browser.close();
  } catch (err) {
    console.error(err);
  }
})();
2
5
2
1
VikramTiwari

comment created time in 2 months

issue commentpuppeteer/puppeteer

page.waitForFunction not ending

Maybe it is worth to provide a minimal complete code that reproduces the issue, with the real URL and selectors.

Pierresibe

comment created time in 2 months

issue commentpuppeteer/puppeteer

page.waitForFunction not ending

To be on the safe side. Are the 2 typos here:

id_disabled = await page.$('Selector[disabled]') == null;

Maybe it should be:

is_disabled = await page.$('#Selector[disabled]') == null;
Pierresibe

comment created time in 2 months

startedphuoc-ng/1loc

started time in 2 months

issue openedpuppeteer/puppeteer

Why can't I see some puppeteer calls in the protocol monitor?

Steps to reproduce

Tell us about your environment:

  • Puppeteer version:3.3.0 (chromium_revision 756035)
  • Platform / OS version: Windows 10 x64
  • Node.js version: 15.0.0-v8-canary20200603908772e6f4

What steps will reproduce the problem?

'use strict';

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch({
      headless: false,
      defaultViewport: null,
      args: ['--lang=en', '--start-maximized'],
      devtools: true,
    });
    const [page] = await browser.pages();

    await page.goto('https://example.org/');

    await page.waitForFunction(
      () => window.protocolMonitorEnabled === true,
      { timeout: 0 }
    );

    // Here I toggle the protocol monitor on, open it,
    //run 'window.protocolMonitorEnabled = true'
    // and click on the page to transfer the focus from the DevTools (just in case).

    await page.waitFor(10000);
    await page.mouse.click(100, 100);

    await page.evaluate(() => {
      document.title = 'New title';
    });
  } catch (err) {
    console.error(err);
  }
})();

What is the expected result?

A bunch of Input.dispatchMouseEvent method calls before the Debugger.scriptParsed call.

What happens instead?

Only the Debugger.scriptParsed call:

1

(Let me know if I should post this to devtools protocol issues instead.)

created time in 2 months

startedkossnocorp/etiquette

started time in 2 months

startedJxck/html2json

started time in 2 months

startedGianlucaTarantino/won

started time in 2 months

startedtesting-library/dom-testing-library

started time in 2 months

startednikfrank/deno-puppeteer-adapter

started time in 2 months

issue commentnodejs/node-v8

No Windows builds since 2020.05.28

FWIW, the recent nightly builds have Windows binaries:

https://nodejs.org/download/nightly/v15.0.0-nightly202005296a1df3b5af/ https://nodejs.org/download/nightly/v15.0.0-nightly20200530d79c330186/ https://nodejs.org/download/nightly/v15.0.0-nightly202005312935f72ae1/

vsemozhetbyt

comment created time in 2 months

issue commentpuppeteer/puppeteer

Failed to install puppeteer

This is optional catch binding, see: https://2ality.com/2017/08/optional-catch-binding.html It is supported since Node.js 10, and current puppeteer versions require Node.js 10 or more. So you need to upgrade the Node.js so that the issue would be fixed.

Sorrismx

comment created time in 2 months

issue openednodejs/node-v8

No Windows builds since 2020.05.28

https://nodejs.org/download/v8-canary/v15.0.0-v8-canary2020053077f9337a58/ https://nodejs.org/download/v8-canary/v15.0.0-v8-canary202005311fd149cdf5/

created time in 2 months

issue commentpuppeteer/puppeteer

Need to take a screenshot from an iframe that loads the content from external sources

You can try to find the frame by its URL among the page.frames() elements and then use frame.waitForSelector() with this frame waiting for some selector available on the iframe complete loading.

aadilwani

comment created time in 2 months

issue commentpuppeteer/puppeteer

Trying to click a div element which match my requirement in puppeteer

You need to send date in browser context of evaluated function as an argument:

var date = '15'
await page.$$eval(".week div", (elements, userDate) => elements.map(item => {
  if (item.textContent == userDate) {
    item.click()
  }
}), date)
lmk07

comment created time in 2 months

issue commentpuppeteer/puppeteer

page.select() doesn't work for multi-select using variable

It seems, by docs, page.select() just needs separate arguments for each selected item - not a single string or array. You can use spread operator for this:

// const desserts = ['chocolate cake', 'apple pie'];
await page.select("#dessert", ...desserts);
vickyrathee

comment created time in 2 months

startedfastify/fastify

started time in 2 months

Pull request review commentnodejs/node

cli: add alias for report-directory to make it consistent

 Write reports in a compact format, single-line JSON, more easily consumable by log processing systems than the default multi-line format designed for human consumption. -### `--report-directory=directory`+### --report-dir=directory`, `report-directory=directory`

Nit: missing backtick.

AshCripps

comment created time in 2 months

startedberstend/puppeteer-extra

started time in 2 months

startedwikimedia/eslint-plugin-no-jquery

started time in 2 months

startedsiefkenj/prettier-plugin-pegjs

started time in 2 months

startedtc39/proposal-upsert

started time in 2 months

startedkitten/reghex

started time in 2 months

startedWebsiteBeaver/far-fetch

started time in 2 months

startedf/omelette

started time in 2 months

startedthisandagain/sentiment

started time in 3 months

startedspion/fast-json-parser

started time in 3 months

startedfresc81/node-winreg

started time in 3 months

issue closednodejs/nodejs.org

Last Chrome Canary cannot download some files

  • URL: https://nodejs.org/download/release/latest/win-x64/, https://nodejs.org/en/download/current/ etc.
  • Browser version: Chrome 84.0.4146.0 canary
  • Operating system: Windows 10 x64

This is just a heads-up cross-post. Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1082683

closed time in 3 months

vsemozhetbyt

issue commentnodejs/nodejs.org

Last Chrome Canary cannot download some files

It seems fixed in the next Chrome version.

vsemozhetbyt

comment created time in 3 months

startedneutralinojs/neutralinojs

started time in 3 months

issue openednodejs/nodejs.org

Last Chrome Canary cannot download some files

  • URL: https://nodejs.org/download/release/latest/win-x64/, https://nodejs.org/en/download/current/ etc.
  • Browser version: Chrome 84.0.4146.0 canary
  • Operating system: Windows 10 x64

This is just a heads-up cross-post. Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1082683

created time in 3 months

startedsallar/stringz

started time in 3 months

issue commentpuppeteer/puppeteer

Cannot install v3.0.0-post from GitHub URL

Still thhe same errors with puppeteer@3.0.4.

vsemozhetbyt

comment created time in 3 months

more