All Projects → webfolderio → Cdp4j

webfolderio / Cdp4j

Licence: other
cdp4j - Chrome DevTools Protocol for Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Cdp4j

Instagram Bot
An Instagram bot developed using the Selenium Framework
Stars: ✭ 138 (-40.52%)
Mutual labels:  automation, crawling, selenium, selenium-webdriver
atata-kendoui
A set of Atata components for Kendo UI
Stars: ✭ 17 (-92.67%)
Mutual labels:  webdriver, selenium, test-automation, selenium-webdriver
page-modeller
⚙️ Browser DevTools extension for modelling web pages for automation.
Stars: ✭ 66 (-71.55%)
Mutual labels:  webdriver, selenium, test-automation, selenium-webdriver
Atata
C#/.NET test automation framework for web
Stars: ✭ 362 (+56.03%)
Mutual labels:  selenium, test-automation, webdriver, selenium-webdriver
Thirtyfour
Selenium WebDriver client for Rust, for automated testing of websites
Stars: ✭ 191 (-17.67%)
Mutual labels:  automation, selenium, webdriver, selenium-webdriver
Sillynium
Automate the creation of Python Selenium Scripts by drawing coloured boxes on webpage elements
Stars: ✭ 100 (-56.9%)
Mutual labels:  automation, selenium, selenium-webdriver, chrome
Element
💦Load test your app using real web browsers
Stars: ✭ 204 (-12.07%)
Mutual labels:  automation, test-automation, webdriver, chrome
Undetected Chromedriver
Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
Stars: ✭ 365 (+57.33%)
Mutual labels:  automation, selenium, webdriver, chrome
Golem
A complete test automation tool
Stars: ✭ 441 (+90.09%)
Mutual labels:  automation, selenium, webdriver, selenium-webdriver
Edge Selenium Tools
An updated EdgeDriver implementation for Selenium 3 with newly-added support for Microsoft Edge (Chromium).
Stars: ✭ 41 (-82.33%)
Mutual labels:  automation, selenium, webdriver, chromium
Pychromeless
Python Lambda Chrome Automation (naming pending)
Stars: ✭ 219 (-5.6%)
Mutual labels:  automation, selenium, chrome, chromium
30 Days Of Python
Learn Python for the next 30 (or so) Days.
Stars: ✭ 1,748 (+653.45%)
Mutual labels:  automation, selenium, selenium-webdriver
Squidwarc
Squidwarc is a high fidelity, user scriptable, archival crawler that uses Chrome or Chromium with or without a head
Stars: ✭ 125 (-46.12%)
Mutual labels:  crawling, chrome, chrome-headless
Panther
A browser testing and web crawling library for PHP and Symfony
Stars: ✭ 2,480 (+968.97%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Marionette
Selenium alternative for Crystal. Browser manipulation without the Java overhead.
Stars: ✭ 119 (-48.71%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Unium
Automation for Unity games
Stars: ✭ 132 (-43.1%)
Mutual labels:  automation, selenium, test-automation
Java.webdriver
Browser test automation using Selenium WebDriver in Java
Stars: ✭ 135 (-41.81%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Webium
Webium is a Page Object pattern implementation library for Python (http://martinfowler.com/bliki/PageObject.html). It allows you to extend WebElement class to your custom controls like Link, Button and group them as pages.
Stars: ✭ 144 (-37.93%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Csharp.webdriver
Browser test automation using Selenium WebDriver in C#
Stars: ✭ 115 (-50.43%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Selenium extensions
Tools that will make writing tests, bots and scrapers using Selenium much easier
Stars: ✭ 140 (-39.66%)
Mutual labels:  selenium, test-automation, selenium-webdriver

cdp4j - Chrome DevTools Protocol for Java

cdp4j is a web-automation library for Java. It can be used for automating the use of web pages and for testing web pages. It use Google Chrome DevTools Protocol to automate Chrome/Chromium based browsers.

Features

  • Supports full capabilities of the Chrome DevTools Protocol (tip-of-tree)
  • Evaluate JavaScript
  • Invoke JavaScript function
  • Supports native CSS selector engine
  • Supports XPath queries
  • Incognito Browsing (private tab)
  • Full page screen capture
  • Trigger Mouse events (click etc...)
  • Send keys (text, tab, enter etc...)
  • Redirect log entries (javascript, network, storage etc...) from browser to slf4j
  • Intercept Network (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

Supported Java Versions

Oracle & OpenJDK Java 8 & 11.

Both the JRE and the JDK are suitable for use with this library.

Licensing

cdp4j is licensed as cdp4j Commercial License.

It's illegal to use cdp4j without having a commercial license.

cdp4j IS NOT A FREE SOFTWARE. Buying a license is mandatory as soon as you develop commercial activities distributing the cdp4j inside your product or deploying it on a network.

Stability

This library is suitable for use in production systems.

Integration with Maven

To use the official release of cdp4j, please use the following snippet in your pom.xml file.

Add the following to your POM's <dependencies> tag:

<dependency>
    <groupId>io.webfolder</groupId>
    <artifactId>cdp4j</artifactId>
    <version>3.0.8</version>
</dependency>

Using development (SNAPSHOT) version:

<dependency>
    <groupId>io.webfolder</groupId>
    <artifactId>cdp4j</artifactId>
    <version>3.0.9-SNAPSHOT</version>
</dependency>

Download

cdp4j-3.0.8.jar - 864 KB

cdp4j-3.0.8-sources.jar - 658 KB

Supported Platforms

cdp4j has been tested under Windows 10, macOS and Ubuntu, but should work on any platform where a Java & Chrome/Chromium available.

Release Notes

CHANGELOG.md

Headless Mode

cdp4j can be run in "headless" mode using with --headless argument.

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

Test headless Chrome

google-chrome --headless --remote-debugging-port=9222 --disable-gpu

JavaDoc

cdp4j api

Logging

Simple logger for Java (SLF4J) and log4j 1.x is supported.

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.

Usage Examples

Print text content with cdp4j

Launcher launcher = new Launcher();
try (SessionFactory factory = launcher.launch();
                    Session session = factory.create()) {
    session.navigate("https://webfolder.io");
    session.waitDocumentReady();
    String content = (String) session.getProperty("//body", "outerText");
    System.out.println(content);
}

Full page screen capture with cdp4j

Launcher launcher = new Launcher();
Path file = createTempFile("screenshot", ".png");
try (SessionFactory factory = launcher.launch();
                    Session session = factory.create()) {
    session.navigate("https://news.ycombinator.com");
    session.waitDocumentReady();
    // activate the tab/session before capturing the screenshot
    session.activate();
    byte[] data = session.captureScreenshot();
    write(file, data);
}
if (isDesktopSupported()) {
    getDesktop().open(file.toFile());
}

Print to PDF with cdp4j

Launcher launcher = new Launcher();
Path file = createTempFile("webfolder-linux-setup", ".pdf");
try (SessionFactory factory = launcher.launch(asList("--headless", "--disable-gpu"))) {
    String context = factory.createBrowserContext();
    try (Session session = factory.create(context)) {
        session.navigate("https://webfolder.io?cdp4j");
        session.waitDocumentReady();
        session.wait(1000);
        byte[] content = session
                            .getCommand()
                            .getPage()
                            .printToPDF();
        write(file, content);
        if (isDesktopSupported()) {
            getDesktop().open(file.toFile());
        }
    }
}

Samples

- - - -
Attributes Bing BingTranslator CheckBox
ExecuteJavascript GoogleTranslate HelloWorld IncognitoBrowsing
Logging MultiSelect NetworkResponse Screenshot
Select SendKeys SharedSession EvaluateOnNewDocument
UserAgent WaitUntil XPathSelector CodeCoverage
PrintToPDF BasicAuthentication DownloadFile Crawler
MultiProcess FollowRedirects CloseSessionOnRedirect Readability
InvokeJavaFromJs InvokeJsFromJava

Building cdp4j

# Assume that you have `google-chrome` in your $PATH
mvn install

# If you use different version of Google Chrome like Chromium, Chrome Canary,
# then you must explicitly use the `chrome_binary` property to make the code work.

mvn install -Dchrome_binary=/path/to/your/google-chrome

# e.g. For some Linux distribution
mvn install -Dchrome_binary=/usr/lib/chromium-dev/chromium-dev

# e.g. MacOS it may be something like
mvn install -Dchrome_binary=/Applications/Chromium.app/Contents/MacOS/Chromium

# To run the existing tests try
mvn test -Dchrome_binary=/usr/lic/chromium-dev/chromium-dev

How it is tested

cdp4j is regularly built and tested on Windows 10 and Ubuntu.

Getting Help

WebFolder

You can support cdp4j development by buying support package. Please contact us for support packages & pricing.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].