@digitalnodecom/node-red-contrib-puppeteer
v1.2.0
Published
NodeRED nodes to control a headless chrome with puppeteer
Downloads
85
Readme
@digitalnodecom/node-red-contrib-puppeteer
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 browserInputsTimeout: numberMaximum time in milliseconds to wait for the browser instance to start. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.Slow Motion: numberSlows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.Hide Chrome: booleanWhether to run browser in headless mode. Defaults to false, it will show Chrome when devtools option is true.Debug Port: numberSpecify custom debugging port. It will connect to existing Chrome if port specified. Pass 0 to discover a random port. Defaults to 0.Show Devtools: booleanWhether to auto-open a DevTools panel for each tab. If this option is true , the Hide Chrome option will be set false.Outputsmsg.puppeteer.browser: objectThe puppeteer browser objectmsg.puppeteer.page: objectThe puppeteer page objectDetailsMust 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 ChromeInputsSelector: stringA selectorto search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.Button: stringSlows 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: numberWhether 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: numberSpecify 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.DetailsThis 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)DetailsThis node closes first chromium page(tab) provided with puppeteer.browser object Page | Content | Get content from pageDetailsThis 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 fileInputsSelector: stringA selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.Button: stringSlows 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: numberDelay: numberDownload path: stringSpecify custom download path. Leave the field blank for default download path. Defaults to user's default browser download path.File name: stringSpecify 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.DetailsThis 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 elementDetailsThis 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 elementDetailsThis 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: stringvalue: stringdomain: stringpath: stringexpires: numbersize: numberhttpOnly: booleansecure: booleansession: booleansameSite: stringsameParty: booleansourceScheme: stringsourcePort: number Page | Go to | Chrome page navigationInputsURL: stringURL to navigate page to. The URL should include scheme, e.g. https://Wait Until: stringWhen 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 ScreenInputsCapture Full Page: booleanWhen true, takes a screenshot of the full scrollable page. Defaults to false.Outputsmsg.payload: Bufferbuffer with captured screenshot.DetailsBrowser screenshot, require focus / active to browser Page | Set | Set value to input fieldDetailsThis 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|requiredvalue: string|requireddomain: string|optional,Default value: '{domain from page object}'path: string|optional,Default value: '/'expires: number|optional,Default value: -1size: number|optional,Default value: {cookie size}httpOnly: boolean|optional,Default value: falsesecure: boolean|optional,Default value: truesession: boolean|optional,Default value: truesameSite: string|optional,Default value: undefinedsameParty: boolean|optional,Default value: falsesourceScheme: string|optional,Default value: 'Secure'sourcePort: number|optional,Default value: 443 Page | Upload | Upload file to specified selectorDetailsThis 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 selectorDetailsThis node awaits for element specified with selector. If the wait timeouts/element doesn't exist, this node throws an error Keyboard | Press | Keyboard PressDetailsThis node presses the keyboard key specified in Key input field. Keyboard | Type | Keyboard TypeDetailsThis node types the text specified in the Text input using the puppeteer.page.keyboard.type function. Storage | Rename | Rename fileInputsOld file path: stringNew file path: stringDetailsThis 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