Module: Symbiont

Includes:
DataSetter, Enclosers, Evaluators, Locators, Platforms
Defined in:
lib/symbiont.rb,
lib/symbiont/logger.rb,
lib/symbiont/factory.rb,
lib/symbiont/version.rb,
lib/symbiont/locators.rb,
lib/symbiont/enclosers.rb,
lib/symbiont/platforms.rb,
lib/symbiont/evaluators.rb,
lib/symbiont/generators.rb,
lib/symbiont/data_setter.rb,
lib/symbiont/web_objects.rb,
lib/symbiont/platform_watir.rb,
lib/symbiont/web_objects/div.rb,
lib/symbiont/web_objects/link.rb,
lib/symbiont/web_objects/span.rb,
lib/symbiont/web_objects/label.rb,
lib/symbiont/web_objects/radio.rb,
lib/symbiont/web_objects/table.rb,
lib/symbiont/web_objects/button.rb,
lib/symbiont/web_objects/option.rb,
lib/symbiont/web_objects/_common.rb,
lib/symbiont/web_objects/heading.rb,
lib/symbiont/web_objects/checkbox.rb,
lib/symbiont/web_objects/list_item.rb,
lib/symbiont/web_objects/paragraph.rb,
lib/symbiont/web_objects/table_row.rb,
lib/symbiont/web_objects/text_area.rb,
lib/symbiont/web_objects/table_cell.rb,
lib/symbiont/web_objects/text_field.rb,
lib/symbiont/web_objects/select_list.rb,
lib/symbiont/web_objects/hidden_field.rb,
lib/symbiont/web_objects/ordered_list.rb,
lib/symbiont/web_objects/unordered_list.rb,
lib/symbiont/platform_watir/platform_object.rb

Defined Under Namespace

Modules: DataSetter, Enclosers, Evaluators, Factory, Generators, Locators, Platforms, WebObjects

Constant Summary collapse

VERSION =
"0.2.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DataSetter

#using

Methods included from Locators

#button_object, #cell_object, #checkbox_object, #div_object, #link_object, #radio_object, #select_list_object, #span_object, #table_object, #text_field_object

Methods included from Evaluators

#back, #focus, #forward, #markup, #refresh, #remove_cookies, #run_script, #screenshot, #text, #title, #url, #visit, #wait_for_app, #wait_for_pending_requests

Methods included from Enclosers

#wait_for, #will_alert, #will_confirm, #will_prompt, #within_frame, #within_modal, #within_window

Methods included from Platforms

#get_platform_for

Instance Attribute Details

#platformObject (readonly)

Used to make a platform object accessible. Will hold object references like these: <Symbiont::Platforms::WatirWebDriver::PlatformObject:0x2cbe8a0>



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

def platform
  @platform
end

Class Method Details

.element_level_waitObject

Returns the default wait value for elements on a page. This value is the default value beyond which a timeout is assumed.



50
51
52
# File 'lib/symbiont.rb', line 50

def self.element_level_wait
  @element_wait ||= 5
end

.element_level_wait=(value) ⇒ Object



54
55
56
# File 'lib/symbiont.rb', line 54

def self.element_level_wait=(value)
  @element_wait = value
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. Those methods will be available only in the context of the class (definition) that included Symbiont.



32
33
34
35
36
# File 'lib/symbiont.rb', line 32

def self.included(caller)
  Symbiont::trace("#{caller.class} #{caller} attached the Symbiont")
  caller.extend Symbiont::Generators
  caller.extend Symbiont::Enclosers
end

.page_level_waitObject

Returns the default wait value for pages. This value is the default value beyond which a timeout is assumed.



40
41
42
# File 'lib/symbiont.rb', line 40

def self.page_level_wait
  @page_wait ||= 15
end

.page_level_wait=(value) ⇒ Object



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

def self.page_level_wait=(value)
  @page_wait = value
end

.trace(message, level = 1) ⇒ Object



2
3
4
# File 'lib/symbiont/logger.rb', line 2

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

.versionObject



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

def self.version
  "Symbiont v#{Symbiont::VERSION}"
end

Instance Method Details

#initialize(browser, visit = nil) ⇒ Object

The initialize method will be invoked when a page definition includes Symbiont. Some key things are happening here that are critical to Symbiont working correctly:

(1) A browser instance is being created.
(2) A platform object is created for that browser.

Parameters:

  • browser (Object)

    a browser instance with a tool driver

  • visit (boolean) (defaults to: nil)

    if true, a definition will be navigated to



66
67
68
69
70
71
72
# File 'lib/symbiont.rb', line 66

def initialize(browser, visit=nil)
  Symbiont::trace("Symbiont attached to browser: #{browser}")
  @browser = browser
  establish_platform_object_for(browser)
  view if visit && respond_to?(:view)
  start if visit && respond_to?(:start)
end