Skip to content

No argument is passed to waitForFunction/waitFor #770

@entrptaher

Description

@entrptaher

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: ^0.10.2
  • Platform / OS version: Ubuntu 16.04.2 LTS

What steps will reproduce the problem?

Problem 1: arguments passed to waitFor is undefined:

  1. Pass any argument to waitFor or waitForFunction.
  2. Get/Call that argument inside the function.
  3. It's undefined.

Problem 2: arguments property inside page.evaluate is undefined.

  1. Call arguments inside any page.evaluate function.
  2. It's undefined and results in TypeError.
const puppeteer = require('puppeteer');
(async() => {
  const browser = await puppeteer.launch({headless: false});

  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.waitForFunction((args) => {
     
    // some tests to show what is happeneing.
    console.log([
      args, // should show args
      arguments, // should not have 0 elements
      Array.isArray(args), // should return True
      Array.isArray([1, 2, 3, 4]) // should return True
    ]);

    return Array.isArray(args);
  }, [1, 2, 3, 4]); // no matter what you pass, it's still undefined;

  await page.screenshot({path: 'example.png'});
  //browser.close();
})();

Meanwhile, the evaluate method shows arguments as undefined while the args provided is working properly.

await page.evaluate((args) => {
    // shows `ReferenceError: arguments is not defined`
    console.log(arguments)

    // runs properly
    console.log([
      args,
      Array.isArray(args),
      Array.isArray([1, 2, 3, 4])
    ]);

    return Array.isArray(args);
  }, [1, 2, 3, 4]);

What is the expected result?
It should behave like page evaluate and the arguments should be passed properly.

What happens instead?
Arguments are not passed.
Waits are timed out.

Screenshot of console with the code ran thru.
image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions