Module: Symbiont

Defined in:
lib/symbiont.rb,
lib/symbiont/pages.rb,
lib/symbiont/ready.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,
lib/symbiont/soap_methods.rb,
lib/symbiont/capybara/page.rb,
lib/symbiont/capybara/region.rb,
lib/symbiont/service_objects.rb,
lib/symbiont/capybara/element.rb

Defined Under Namespace

Modules: Accessor, Assertion, DataBuilder, DataReader, DataSetter, Element, Elements, Errors, Factory, Helpers, Pages, Ready, SoapObject Classes: Page, Region

Constant Summary collapse

VERSION =
'1.2.0'

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.selectableObject

Returns the value of attribute selectable.



7
8
9
# File 'lib/symbiont/elements.rb', line 7

def selectable
  @selectable
end

.settableObject

Returns the value of attribute settable.



7
8
9
# File 'lib/symbiont/elements.rb', line 7

def settable
  @settable
end

.use_implicit_waitsObject

Returns the value of attribute use_implicit_waits.



88
89
90
# File 'lib/symbiont.rb', line 88

def use_implicit_waits
  @use_implicit_waits
end

Instance Attribute Details

#browserObject (readonly)

Returns browser driver reference.

Returns:

  • (Object)

    browser driver reference



66
67
68
# File 'lib/symbiont.rb', line 66

def browser
  @browser
end

Class Method Details

.browserObject



52
53
54
# File 'lib/symbiont.rb', line 52

def self.browser
  @browser
end

.browser=(browser) ⇒ Object



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

def self.browser=(browser)
  @browser = browser
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Symbiont)

    the object that the method was called on



90
91
92
# File 'lib/symbiont.rb', line 90

def configure
  yield self
end

.elementsObject



9
10
11
12
13
14
15
# File 'lib/symbiont/elements.rb', line 9

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

.included(caller) ⇒ Object

Parameters:

  • caller (Class)

    the class including the framework



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

def self.included(caller)
  caller.extend Symbiont::Assertion
  caller.extend Symbiont::Elements
  caller.send :include, Symbiont::Pages
  caller.send :include, Symbiont::Ready
  caller.send :include, Symbiont::Accessor
  caller.send :include, Symbiont::DataSetter
  caller.send :include, Symbiont::DataBuilder

  caller.page_ready do
    [displayed?, "Expected #{current_url} to match #{url_match} but it did not."]
  end

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

.selectable?(element) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/symbiont/elements.rb', line 29

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

.set_browser(app = :firefox, *args) ⇒ Object



81
82
83
84
# File 'lib/symbiont.rb', line 81

def self.set_browser(app = :firefox, *args)
  @browser = Watir::Browser.new(app, *args)
  Symbiont.browser = @browser
end

.settable?(element) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.trace(message, level = 1) ⇒ Object



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

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

.versionObject



56
57
58
59
60
61
62
63
# File 'lib/symbiont.rb', line 56

def self.version
  """
Symbiont v#{Symbiont::VERSION}
Watir-WebDriver: #{Gem.loaded_specs['watir-webdriver'].version}
Selenium-WebDriver: #{Gem.loaded_specs['selenium-webdriver'].version}
Capybara: #{Gem.loaded_specs['capybara'].version}
  """
end

Instance Method Details

#initialize(browser = nil, &block) ⇒ Object

Parameters:

  • browser (Object) (defaults to: nil)

    a tool driver instance



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/symbiont.rb', line 69

def initialize(browser = nil, &block)
  Symbiont.trace("Symbiont attached to browser:\n\t#{browser.inspect}")

  @browser = Symbiont.browser unless Symbiont.browser.nil?
  @browser = browser if Symbiont.browser.nil?

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

  instance_eval(&block) if block
end