Sign inSign up

jim3mar/phantomjs

By jim3mar

Updated about 10 years ago

PhantomJS 2 is a headless WebKit scriptable (browser) with a JavaScript API

Image
0

426

jim3mar/phantomjs repository overview

Docker container of PhantomJS is a headless WebKit browser, often used via WebDriver for web system testing:

  • Small: Using Debian image is 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).
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.

Tag summary

Content type

Image

Digest

Size

81.7 MB

Last updated

about 10 years ago

docker pull jim3mar/phantomjs