@digitalnodecom/node-red-contrib-puppeteer 1.1.0

NodeRED nodes to control a headless chrome with puppeteer

npm install @digitalnodecom/node-red-contrib-puppeteer

drawing drawing

These node-red nodes expose puppeteer's API used for controlling Chrome/Chromium over the DevTools Protocol

Group Node Name Detailed information
Browser Launch

Launch Chrome browser

Inputs

Timeout: number
Maximum time in milliseconds to wait for the browser instance to start. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
Slow Motion: number
Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.
Hide Chrome: boolean
Whether to run browser in headless mode. Defaults to false, it will show Chrome when devtools option is true.
Debug Port: number
Specify custom debugging port. It will connect to existing Chrome if port specified. Pass 0 to discover a random port. Defaults to 0.
Show Devtools: boolean
Whether to auto-open a DevTools panel for each tab. If this option is true , the Hide Chrome option will be set false.

Outputs

msg.puppeteer.browser: object
The puppeteer browser object
msg.puppeteer.page: object
The puppeteer page object

Details

Must launch Chrome browser before run any puppeteer actions

Browser New Page This node creates/opens new page(tab) in existing chromium instance or rather puppeteer.browser object
Browser Close Browser This node closes chromium browser instance provided with puppeteer.browser object
Page Click

Click on Chrome

Inputs

Selector: string
selectorto search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.
Button: string
Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.<"left"|"right"|"middle"> Defaults to left.
Click Count: number
Whether to run browser in  headless mode. Defaults to false, it will show Chrome when devtools option is true. Defaults to 1. See UIEvent.detail.
Delay: number
Specify custom debugging port. Pass 0  to discover a random port. Defaults to 0. Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.

Details

This node fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the node throws an error.

Page Close

Close first chromium page(tab)

Details

This node closes first chromium page(tab) provided with puppeteer.browser object

Page Content

Get content from page

Details

This node gets page's content from puppeteer.page object

Page Delete Cookies This node deletes all the cookies from the passed puppeteer.page object
Page Download

Dowload a file

Inputs

Selector: string
selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.
Button: string
Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.<"left"|"right"|"middle"> Defaults to left.
Click Count: number
Delay: number
Download path: string
Specify custom download path. Leave the field blank for default download path. Defaults to user's default browser download path.
File name: string
Specify custom file name. Leave the field blank for default file name. Please note that in order for this to work this node needs to be followed by the rename node(in storage section). Defaults to default file name.

Details

This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error. The main difference between this and click node is that with this node you can specify download path and file name. But, in order the custom filename to work, this node must have download path and file name specified and be followed by a rename node(in storage section)where the old file path should be set to msg.old and the new file path should be set to msg.new

Page Focus

Focus on element

Details

This node fetches an element with selector and puts it in focus. If there's no element matching selector, the node throws an error.

Page Get

Get property value from element

Details

This node fetches a specified property value from element with specified selector . If there's no element matching the selector, the node throws an error.

Page Get Cookies
This node retrieves all cookies using the passed page object as input (msg.puppeteer.page). This node otputs list of cookies in msg.payload property. Each object contains the following properties:
  • name: string
  • value: string
  • domain: string
  • path: string
  • expires: number
  • size: number
  • httpOnly: boolean
  • secure: boolean
  • session: boolean
  • sameSite: string
  • sameParty: boolean
  • sourceScheme: string
  • sourcePort: number
Page Go to

Chrome page navigation

Inputs

URL: string
URL to navigate page to. The URL should include scheme, e.g. https://
Wait Until: string
When to consider navigation succeeded. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:
load : consider navigation to be finished when the load event is fired.
domcontentloaded : consider navigation to be finished when the DOMContentLoaded event is fired.
networkidle0 : consider navigation to be finished when there are no more than 0 network connections for at least 500 ms.
networkidle2 : consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
Page Screenshot

Capture Screen

Inputs

Capture Full Page: boolean
When true, takes a screenshot of the full scrollable page. Defaults to false.

Outputs

msg.payload: Buffer
buffer with captured screenshot.

Details

Browser screenshot, require focus / active to browser

Page Set

Set value to input field

Details

This node fetches an element with selector and if the element is input field it changes its value to the value specified in the Value field. If there's no element matching selector, the node throws an error.

Page Set Cookies
This node sets the cookies on the current page object. The input page object should be passed as msg.puppeteer.page. The cookies should be a list of cookie objects where each one has the following properties and they should be passed in as msg.payload, or if directly into the input field it should be a valid JSON list:
  • name: string|required
  • value: string|required
  • domain: string|optional,
    Default value: '{domain from page object}'
  • path: string|optional,
    Default value: '/'
  • expires: number|optional,
    Default value: -1
  • size: number|optional,
    Default value: {cookie size}
  • httpOnly: boolean|optional,
    Default value: false
  • secure: boolean|optional,
    Default value: true
  • session: boolean|optional,
    Default value: true
  • sameSite: string|optional,
    Default value: undefined
  • sameParty: boolean|optional,
    Default value: false
  • sourceScheme: string|optional,
    Default value: 'Secure'
  • sourcePort: number|optional,
    Default value: 443
Page Upload

Upload file to specified selector

Details

This node uploads a file(or more accurately specified filePath) specified with Upload File to the element speicified with the selector if it exists.

Page Wait for

Wait for selector

Details

This node awaits for element specified with selector. If the wait timeouts/element doesn't exist, this node throws an error

Keyboard Press

Keyboard Press

Details

This node presses the keyboard key specified in Key input field.

Keyboard Type

Keyboard Type

Details

This node types the text specified in the Text input using the puppeteer.page.keyboard.type function.

Storage Rename

Rename file

Inputs

Old file path: string
New file path: string

Details

This node renames the file from old file path to the new file path, or essetially it moves it from one location to another if that is how the paths are specified.

Install these nodes using the following command or directly via node-red dashboard

npm install @digitalnodecom/node-red-contrib-puppeteer

Credits

Original fork

The original package started development in this repository. Thank you oliverlorenz for the initiative!

Forked from

Thanks to d0uub for picking up the development of the original repository and continuing it in the following repo. We forked from this repo and created this package by adding nodes and improving node's documentation!

Palettes

By coolors.co

Icons

By fontawesome and svgrepo

Node Info

Version: 1.1.0
Updated 2 months, 1 week ago
License: MIT
Rating: 5.0 1

Actions

Rate:

Downloads

63 in the last week

Nodes

  • puppeteer-browser-launch
  • puppeteer-browser-close
  • puppeteer-browser-newPage
  • puppeteer-page-goto
  • puppeteer-page-screenshot
  • puppeteer-page-content
  • puppeteer-page-click
  • puppeteer-page-download
  • puppeteer-page-focus
  • puppeteer-page-waitFor
  • puppeteer-page-getCookies
  • puppeteer-page-setCookies
  • puppeteer-page-deleteCookies
  • puppeteer-page-close
  • puppeteer-page-keyboard-type
  • puppeteer-page-keyboard-press
  • puppeteer-page-get-value
  • puppeteer-page-set-value
  • puppeteer-page-upload
  • puppeteer-rename

Keywords

  • chrome
  • browser automation
  • puppeteer
  • node-red

Maintainers