Git Product home page Git Product logo

jbrowserdriver's Introduction

jBrowserDriver

A programmable, embedded web browser driver compatible with the Selenium WebDriver spec -- fast, headless, WebKit-based, 100% pure Java, and no browser dependencies

Licensed under the Apache License v2.0 (details).

Contact [email protected] to sponsor development of new features, have jBrowserDriver integrated into your project, or get warranty & support.


Download

Get a ZIP archive of the latest release.

Or install via Maven:

<dependency>
  <groupId>com.machinepublishers</groupId>
  <artifactId>jbrowserdriver</artifactId>
  <version>[0.10.1, 2.0)</version>
</dependency>

For other install options, see the Central Repository.

Pre-requisites

There's no need to install any web browser and this works fine on a server (headless). Java 8 (Oracle JDK/JRE or OpenJDK) is required.

Linux users: on Debian/Ubuntu install the following, apt-get install openjdk-8-jdk openjfx

Usage

For specific details, refer to the API documentation.

Use this library like any other Selenium WebDriver or RemoteWebDriver. It also works with Selenium Server (use browser name "jbrowserdriver").

You can optionally create a Settings object, configure it, and pass it to the JBrowserDriver constructor to specify a proxy, request headers, time zone, user agent, or navigator details. By default, the browser mimics the fingerprint of Tor Browser.

Settings can alternately be configured using Java system properties or Selenium Capabilities. See Settings builder documentation for details.

Each instance of JBrowserDriver is backed by a separate Java process, so any native browser crashes will not take down your app.

Example:

import org.openqa.selenium.WebDriver;
import com.machinepublishers.jbrowserdriver.Timezone;
import com.machinepublishers.jbrowserdriver.JBrowserDriver;
import com.machinepublishers.jbrowserdriver.Settings;
    
public class Example {
  public static void main(String[] args) {

    // You can optionally pass a Settings object here,
    // constructed using Settings.Builder
    JBrowserDriver driver = new JBrowserDriver(Settings.builder().
      timezone(Timezone.AMERICA_NEWYORK).build());

    // This will block for the page load and any
    // associated AJAX requests
    driver.get("http://example.com");

    // You can get status code unlike other Selenium drivers.
    // It blocks for AJAX requests and page loads after clicks 
    // and keyboard events.
    System.out.println(driver.getStatusCode());

    // Returns the page source in its current state, including
    // any DOM updates that occurred after page load
    System.out.println(driver.getPageSource());
    
    // Close the browser. Allows this thread to terminate.
    driver.quit();
  }
}

Building

Install and configure Maven v3.x (which is also available in most Linux package repos) and then from the project root run mvn clean compile install. To use in Eclipse, either import the existing Java project from the root directory or import the pom.xml file via the M2E plugin. However, if you merely want to use this as a dependency in a separate project, see the Download section. Pull requests are welcome, and we ask contributors to agree to the CLA. Feel free to discuss bugs and new features by opening a new issue.


Copyright (C) 2014-2016 Machine Publishers, LLC

jbrowserdriver's People

Contributors

hollingsworthd avatar qqilihq avatar glmeece avatar travis-rodman avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.