cdp4j - Browser automation libray for Java
cdp4j is Java library with a clear and concise API to automate Chrome/Chromium based browser. It use Google Chrome DevTools Protocol to automate Chrome/Chromium based browsers.
What can you do with cdp4j?
Most things that you can do manually in the browser can be done using cdp4j. Here are a few examples to get you started:
- Generate screenshots and PDFs of pages.
- Crawl a Single-Page Application and generate pre-rendered content (Server-Side Rendering).
- Automate form submission, UI testing, keyboard input, etc.
- Create an up-to-date, automated testing environment.
How to run examples?
- Download the archive file.
- Extract the archive file.
- Launch the Eclipsle and import the project (File -> Import > Existing Projects into Workspace)
- Launch the Intellij and import the Eclipse project.
- Supports full capabilities of the Chrome DevTools Protocol (tip-of-tree)
- PDF printer
- Supports native CSS selector engine
- iframe support
- Supports XPath queries
- Incognito Browsing (private tab)
- Full page screen capture
- Support parallel running
- Auto-Wait for DOM change completion
- Trigger Mouse events (click etc...)
- Send keys (text, tab, enter etc...)
- playwright selectors
- Intercept Network traffic (request & response)
- Upload file programmatically without third party solutions (does not requires AWT Robot etc...)
- get & set Element properties
- Supports Headless Chrome/Chromium
- Navigate back, forward, stop, reload
- clear cache, clear cookies, list cookies
- set & get values of form elements
- Supports event handling
- Supports all well known Java WebSocket libraries.
Supported Java Versions
Oracle/OpenJDK 8+, GraalVM & native-image.
Both the JRE and the JDK are suitable for use with this library.
This library is suitable for use in production systems. Our library is used by many well known enterprise customers.
cdp4j has been tested under Windows 10 and Ubuntu, but should work on any platform where a Java 8+/Graal VM native-image & Chrome/Chromium/Microsoft Edge available.
Note: Although we do not execute test suites on Mac, many customers run cdp4j without any problem. Please do not hesitate to report bugs related with Mac.
cdp4j can be run in "headless" mode using with
slf4j 1.x, log4j 1.x, JUL and custom Console logger is supported.
Note: Please let us know if your preferred logging library is not listed.
DevTools Protocol uses WebSocket protocol to automate Chromium based browser. We supports the following Java WebSocket libraries.
- Jre WebSocket Library (requires Java 11+).
Note: Please let us know if your preferred WebSocket library is not listed.
We provide many examples to show how to use cdp4j library. It's highly recommended to run these examples before starting to use cdp4j.
- Avoid external dependencies as much as possible.
- Support only Chrome/Chromium based browsers.
- Supports full capabilities of the Chrome DevTools Protocol.
- Keep the API simple.
- Support GraalVM Native Image.
How it is tested
cdp4j is regularly built and tested on Windows 10 and Ubuntu.
Support & Bug Report
Please report your bugs and new features by e-mail (email@example.com). github issues is only used by cdp4j developers.