Code Monkey home page Code Monkey logo

docker-phantomjs's Introduction

Supported tags and respective Dockerfile links

What is PhantomJS

PhantomJS is a headless WebKit browser, often used via WebDriver for web system testing. It's based on WebKit, runs JavaScript, and allows to take screenshots.

Features of this image

This Dockerized version of PhantomJS is:

  • Small: Using Debian image (below 100 MB, while Ubuntu is about 230 MB), and removing packages used during build.
  • Simple: Exposes default port, easy to extend.
  • Secure: Runs as non-root UID/GID 72379 (selected randomly to avoid mapping to an existing user) and uses dumb-init to reap zombie processes.

Usage

JavaScript interactive shell

Start PhantomJS in REPL:

$ docker run --rm wernight/phantomjs
>

Remote WebDriver

Start as 'Remote WebDriver mode' (embedded GhostDriver):

$ docker run -d -p 8910:8910 wernight/phantomjs phantomjs --webdriver=8910

To connect to it (some examples per language):

  • Java:

    WebDriver driver = new RemoteWebDriver(
        new URL("http://127.0.0.1:8910"),
        DesiredCapabilities.phantomjs());
    
  • Python (after running $ pip install selenium):

    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    driver = webdriver.Remote(
        command_executor='http://127.0.0.1:8910',
        desired_capabilities=DesiredCapabilities.PHANTOMJS)
    
    driver.get('http://example.com')
    driver.find_element_by_css_selector('a[title="hello"]').click()
    
    driver.quit()
    

Feedbacks

Improvement ideas and pull requests are welcome via Github Issue Tracker.

docker-phantomjs's People

Contributors

wernight avatar jefmathiot avatar shingara avatar

Watchers

James Cloos 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.