Giter VIP home page Giter VIP logo

webdriver's Introduction

WebDriver

Build Status

WebDriver is a wire based protocol drafted by the W3C in order to provide browsers with scripting capability. WebDriver-enabled browsers include Chrome, Firefox, Safari, Internet Explorer and PhantomJs. These browsers can be requested to execute JavaScript, load urls, enquire upon doms and more.

This project provides an alternate WebDriver implementation based on Scala, Akka and Spray. The primary benefit of the approach taken here as opposed to many of the existing WebDriver APIs is its reactive nature i.e. the API is non-blocking and event driven, providing a resilient implementation by leveraging Akka in particular. One consequence of the API design is that many WebDriver requests can be executed in parallel e.g. several JavaScript programs can be run simultaneously.

In addition to the reactive network client, support for HtmlUnit is provided. HtmlUnit provides a browser environment to Mozilla's Rhino and executes entirely within the JVM. The consequence of this is that no other browser is required to be installed. The cost is one of performance given that Rhino is not faster than a native browser. That said, HtmlUnit is invoked across multiple threads and so performance may be adequate for many use-cases.

Sample usage can be obtained by inspecting the webdriver-tester sub-project. There's a main class that illustrates essential interactions. Here is a snippet of it:

val browser = system.actorOf(PhantomJs.props(), "localBrowser")
browser ! LocalBrowser.Startup
for (
  session <- (browser ? LocalBrowser.CreateSession).mapTo[ActorRef];
  result <- (session ? Session.ExecuteJs("return arguments[0]", JsArray(JsNumber(999)))).mapTo[JsNumber]
) yield {
  println(result)
  ...

The above illustrates how a browser can be launched, a session established and then some arbitrary JavaScript sent to it through the session.

© Typesafe Inc., 2013, 2014

webdriver's People

Contributors

huntc avatar jroper avatar

Watchers

Frédéric Nowak avatar James Cloos 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.