TypeError: Cannot read properties of undefined (reading 'props')

This is my first code in my life.

I try to use a puppeteer.
If I click “test” SUCCESS - code works OK
but if I use trigger SCHEDULE (run code one per day ) - Puppeteer
and RUN NOW option and I will wait until the appropriate designated time to execute the code
I see the error:

TypeError: Cannot read properties of undefined (reading ‘props’)

Error: TypeError: Cannot read properties of undefined (reading 'props')
    at handleError (/var/task/common.js:38:40)
    at Runner.runUserCode (file:///var/task/lambda_handler.mjs:901:9)
    at async Runner.run (file:///var/task/lambda_handler.mjs:732:5)
    at async Runtime.handler (file:///var/task/lambda_handler.mjs:952:22)

(puppeteer)

code:

import { puppeteer } from ‘@pipedream/browsers’;

//const puppeteer = require(‘puppeteer’);

async function automateTask() {
// Open the browser in headless mode
const browser = await puppeteer.launch({ headless: false });

// Go to the website
const page = await browser.newPage();
await page.goto(‘https://www.somepage.com’);

/*
const zamknij = await page.waitForSelector(‘#content > section > div.cookies-alert-block > a > p’)
await zamknij.click()
*/
const serwisyinformacyjne = await page.waitForSelector(‘label.select-all-’)
await serwisyinformacyjne.click()

const wpisztelefon = await page.waitForSelector(‘input#phone’)
await wpisztelefon.click()

await wpisztelefon.type(‘555123123’);

const wymagane = await page.waitForSelector(‘.checkbox > .res’)
await wymagane.click()

const wyslij = await page.waitForSelector(‘.form-group > .black.btn’)

await wyslij.click()

await page.waitForTimeout(5000);

await browser.close();
}

automateTask();

Hi @fbox3tv33,

It looks like you’re trying to use Puppeteer in a Pipedream workflow. To use Puppeteer in Pipedream, you should use the provided puppeteer package from @pipedream/browsers and write your code within a Pipedream component. Here’s an example of how to structure your code as a Pipedream component:

import { puppeteer } from "@pipedream/browsers";

export default defineComponent({
  async run({ steps, $ }) {
    const browser = await puppeteer.browser();
    const page = await browser.newPage();
    await page.goto("https://www.somepage.com");

    // Your Puppeteer code here

    await browser.close();
  },
});

Replace the comment // Your Puppeteer code here with the rest of your Puppeteer code. Make sure to remove the automateTask() function call at the end of your code, since the run method will be executed automatically when the workflow runs.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

1 Like

THANKS, Little AI.
Now my code works OK.