Sign inSign up

fabiocicerchia/phantomjs

By fabiocicerchia

•Updated over 6 years ago
Archived

PhantomJS 3 is a headless WebKit scriptable (browser) with a JavaScript API (Debian, Ubuntu, Fedora)

Image
0

770

fabiocicerchia/phantomjs repository overview

⁠PhantomJS Docker Image

⁠What is PhantomJS

PhantomJS⁠ is a headless WebKit scriptable with JavaScript. Often used via WebDriver⁠ for web system testing.

⁠Use Cases
  • Headless web testing. Lightning-fast testing without the browser is now possible!
  • Page automation. Access and manipulate⁠ web pages with the standard DOM API, or with usual libraries like jQuery.
  • Screen capture. Programmatically capture web contents⁠, including CSS, SVG and Canvas. Build server-side web graphics apps, from a screenshot service to a vector chart rasterizer.
  • Network monitoring. Automate performance analysis, track page loading⁠ and export as standard HAR format.

⁠Features of this image

This Dockerized⁠ version of PhantomJS is:

  • Small: Using Debian image⁠, and removing packages used during build.
  • Simple: Exposes default port, easy to extend.
  • Secure: Runs as non-root UID/GID 19534 (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 -it --rm fabiocicerchia/phantomjs
>
⁠Remote WebDriver

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

$ docker run -d -p 8910:8910 fabiocicerchia/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⁠.

Tag summary

Content type

Image

Digest

Size

158.7 MB

Last updated

over 6 years ago

docker pull fabiocicerchia/phantomjs