Important Announcement: New versions is not released to GitHub and not publicly available. Please contact us to download new cdp4j versions.
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?
- Automatically fill-out forms. You can easily download and upload of text, images, handle PDF files, or take screenshots.
- Import or export data to and from web applications.
- Extract Any Kind of Data from the Web.
- Automate Web Upload/Download.
Main Features
- Supports full capabilities of the Chrome DevTools Protocol (tip-of-tree)
- PDF printer
- Evaluate JavaScript
- Invoke JavaScript function
- Invoke Java function from Browser (JavaScript)
- Supports native CSS selector engine
- 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...)
- Redirect log entries (javascript, network, storage etc...) from browser to slf4j, log4j or console logger.
- 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, GraalVM Native Image.
Both the JRE and the JDK are suitable for use with this library.
Note: We only support LTS versions (8 & 11).
Stability
This library is suitable for use in production systems. Our library is used by many well known enterprise customers.
Download
Maven Integration
Install artifacts for Windows:
mvn deploy:deploy-file -DgroupId=io.webfolder -DartifactId=cdp4j -Dversion=4.2.2 -Dfile=cdp4j-4.2.2.jar -Dpackaging=jar -Durl=file://%USERPROFILE%\.m2\repository
Install artifacts for Nix:
mvn deploy:deploy-file -DgroupId=io.webfolder -DartifactId=cdp4j -Dversion=4.2.2 -Dfile=cdp4j-java-4.2.2.jar -Dpackaging=jar -Durl=file://$HOME/.m2/repository
Supported Platforms
cdp4j has been tested under Windows 10 and Ubuntu, but should work on any platform where a Java 8+/Graal VM/Substrate VM & 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.
Release Notes
Headless Mode
cdp4j can be run in "headless" mode using with Options.headless(boolean)
option.
Install Chrome on Debian/Ubuntu
# https://askubuntu.com/questions/79280/how-to-install-chrome-browser-properly-via-command-line
sudo apt-get install libxss1 libappindicator1 libappindicator3-1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb # Might show "errors", fixed by next line
sudo apt-get install -f
Install Chrome on RHEL/CentOS/Fedora
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
sudo yum install google-chrome-stable_current_*.rpm
JavaDoc
Logging
slf4j 1.x, log4j 1.x and custom Console logger is supported.
Note: Please let us know if your preferred logging library is not listed.
WebSocket Protocol
DevTools Protocol uses WebSocket protocol to automate Chromium based browser. We supports the following Java WebSocket libraries.
- Jre WebSocket Library (requires Java 11+).
- Jetty
- Undertow
- Vertx
- Tyrus
- TooTallNateWebSocket
- Tomcat
- Netty
- NvWebSocket
Note: Please let us know if your preferred WebSocket library is not listed.
Examples
We provide many examples to show how to use cdp4j library. It's highly recommended to run these examples before starting to use cdp4j.
Design Principles
- 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 protected]). github issues is only used by cdp4j developers.
License
cdp4j is a proprietary software which means that you or your company needs commercial license to use cdp4j.
Trial
You are free to use this library for only development purpose. It's not require to buy commercial for trial usage. Production systems requires commercial license without any exception.