Module: Symbiont

Defined in:
lib/symbiont.rb,
lib/symbiont/pages.rb,
lib/symbiont/errors.rb,
lib/symbiont/factory.rb,
lib/symbiont/helpers.rb,
lib/symbiont/version.rb,
lib/symbiont/accessor.rb,
lib/symbiont/elements.rb,
lib/symbiont/assertions.rb,
lib/symbiont/data_reader.rb,
lib/symbiont/data_setter.rb,
lib/symbiont/data_builder.rb

Defined Under Namespace

Modules: Accessor, Assertion, DataBuilder, DataReader, DataSetter, Element, Errors, Factory, Helpers, Page

Constant Summary collapse

VERSION =
'0.8.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#browserObject (readonly)

Returns browser driver reference.

Returns:

  • (Object)

    browser driver reference



48
49
50
# File 'lib/symbiont.rb', line 48

def browser
  @browser
end

Class Method Details

.elementsArray

Calls the Watir module to get a list of the factory methods that Watir uses to reference and access web objects.

Returns:

  • (Array)

    factory method list



6
7
8
9
10
11
12
# File 'lib/symbiont/elements.rb', line 6

def self.elements
  unless @elements
    @elements = Watir::Container.instance_methods
    #@elements.delete(:extract_selector)
  end
  @elements
end

.included(caller) ⇒ Object

The included callback is used to provide the core functionality of the library to any class or module that includes the Symbiont library. The calling class or module is extended with logic that the library makes available as class methods. Any such class or module becomes a page or activity definition. The class methods allow assertions and element defintions to be defined.

Parameters:

  • caller (Class)

    the class including the framework



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/symbiont.rb', line 30

def self.included(caller)
  caller.extend Symbiont::Assertion
  caller.extend Symbiont::Element
  
  caller.send :include, Symbiont::Page
  caller.send :include, Symbiont::Accessor

  caller.send :include, Symbiont::DataSetter
  caller.send :include, Symbiont::DataBuilder

  Symbiont.trace("#{caller.class} #{caller} has attached the Symbiont.")
end

.selectableObject



18
19
20
# File 'lib/symbiont/elements.rb', line 18

def self.selectable
  @selectable ||= [:select_list]
end

.selectable?(element) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/symbiont/elements.rb', line 26

def self.selectable?(element)
  selectable.include? element.to_sym
end

.settableObject



14
15
16
# File 'lib/symbiont/elements.rb', line 14

def self.settable
  @settable ||= [:text_field, :file_field, :textarea]
end

.settable?(element) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/symbiont/elements.rb', line 22

def self.settable?(element)
  settable.include? element.to_sym
end

.trace(message, level = 1) ⇒ Object



43
44
45
# File 'lib/symbiont.rb', line 43

def self.trace(message, level = 1)
  puts '*' * level + " #{message}" if ENV['SYMBIONT_TRACE'] == 'on'
end

Instance Method Details

#initialize(driver) ⇒ Object

Parameters:

  • driver (Object)

    a tool driver instance



51
52
53
54
55
56
57
# File 'lib/symbiont.rb', line 51

def initialize(driver)
  Symbiont.trace("Symbiont attached to browser:\n\t#{driver.inspect}")
  @browser = driver

  initialize_page if respond_to?(:initialize_page)
  initialize_activity if respond_to?(:initialize_activity)
end