Class Headless
In: lib/headless.rb
lib/headless/video/video_recorder.rb
lib/headless/cli_util.rb
Parent: Object

A class incapsulating the creation and usage of a headless X server

Prerequisites

  • X Window System
  • Xvfb

Usage

Block mode:

  require 'rubygems'
  require 'headless'
  require 'selenium-webdriver'

  Headless.ly do
    driver = Selenium::WebDriver.for :firefox
    driver.navigate.to 'http://google.com'
    puts driver.title
  end

Object mode:

  require 'rubygems'
  require 'headless'
  require 'selenium-webdriver'

  headless = Headless.new
  headless.start

  driver = Selenium::WebDriver.for :firefox
  driver.navigate.to 'http://google.com'
  puts driver.title

  headless.destroy

Methods

destroy   new   run   start   stop   take_screenshot   video  

Classes and Modules

Class Headless::CliUtil
Class Headless::Exception
Class Headless::VideoRecorder

Constants

DEFAULT_DISPLAY_NUMBER = 99
MAX_DISPLAY_NUMBER = 10_000
DEFAULT_DISPLAY_DIMENSIONS = '1280x1024x24'
XVFB_LAUNCH_TIMEOUT = 10   How long should we wait for Xvfb to open a display, before assuming that it is frozen (in seconds)

External Aliases

run -> ly

Attributes

dimensions  [R]  The display dimensions
display  [R]  The display number

Public Class methods

Creates a new headless server, but does NOT switch to it immediately. Call start for that

List of available options:

  • display (default 99) - what display number to listen to;
  • reuse (default true) - if given display server already exists, should we use it or try another?
  • autopick (default true is display number isn‘t explicitly set) - if Headless should automatically pick a display, or fail if the given one is not available.
  • dimensions (default 1280x1024x24) - display dimensions and depth. Not all combinations are possible, refer to +man Xvfb+.
  • destroy_at_exit (default true) - if a display is started but not stopped, should it be destroyed when the script finishes?

Block syntax:

  Headless.run do
    # perform operations in headless mode
  end

See new for options

Public Instance methods

Switches back from the headless server and terminates the headless session

Switches to the headless server

Switches back from the headless server

[Validate]