Module: Tapestry

Defined in:
lib/tapestry.rb,
lib/tapestry/ready.rb,
lib/tapestry/errors.rb,
lib/tapestry/element.rb,
lib/tapestry/factory.rb,
lib/tapestry/version.rb,
lib/tapestry/attribute.rb,
lib/tapestry/interface.rb,
lib/tapestry/situation.rb,
lib/tapestry/extensions/data_setter.rb

Defined Under Namespace

Modules: DataSetter, Element, Errors, Factory, Interface, Locator, Ready, Situation

Constant Summary collapse

NATIVE_QUALIFIERS =
i[visible].freeze
VERSION =
"0.7.0".freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.browserObject

This accessor is needed so that Tapestry itself can provide a browser reference to indicate connection to WebDriver. This is a class-level access to the browser.



41
42
43
# File 'lib/tapestry.rb', line 41

def browser
  @browser
end

Instance Attribute Details

#browserObject

This accessor is needed so that internal API calls, like ‘markup` or `text`, have access to the browser instance. This is an instance-level access to the browser.



35
36
37
# File 'lib/tapestry.rb', line 35

def browser
  @browser
end

Class Method Details

.dependenciesObject



14
15
16
17
# File 'lib/tapestry/version.rb', line 14

def dependencies
  Gem.loaded_specs.values.map { |spec| "#{spec.name} #{spec.version}\n" }
     .uniq.sort.join(",").split(",")
end

.elementsObject



16
17
18
# File 'lib/tapestry/element.rb', line 16

def elements
  @elements ||= Watir::Container.instance_methods unless @elements
end

.elements?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/tapestry/element.rb', line 8

def elements?
  @elements
end

.gem_version(name) ⇒ Object



19
20
21
22
23
# File 'lib/tapestry/version.rb', line 19

def gem_version(name)
  Gem.loaded_specs[name].version
rescue NoMethodError
  puts "No gem loaded for #{name}."
end

.included(caller) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/tapestry.rb', line 16

def self.included(caller)
  caller.extend Tapestry::Element
  caller.extend Tapestry::Interface::Page::Attribute
  caller.__send__ :include, Tapestry::Ready
  caller.__send__ :include, Tapestry::Locator
  caller.__send__ :include, Tapestry::Interface::Page
  caller.__send__ :include, Tapestry::DataSetter
end

.quit_browserObject



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

def quit_browser
  @browser.quit
end

.recognizes?(method) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/tapestry/element.rb', line 12

def recognizes?(method)
  @elements.include? method.to_sym
end

.set_browser(app = :chrome, *args) ⇒ Object Also known as: start_browser



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

def set_browser(app = :chrome, *args)
  @browser = Watir::Browser.new(app, *args)
  Tapestry.browser = @browser
end

.versionObject



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

def version
  """
Tapestry v#{Tapestry::VERSION}
watir: #{gem_version('watir')}
selenium-webdriver: #{gem_version('selenium-webdriver')}
  """
end

Instance Method Details

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



25
26
27
28
29
30
# File 'lib/tapestry.rb', line 25

def initialize(browser = nil, &block)
  @browser = Tapestry.browser unless Tapestry.browser.nil?
  @browser = browser if Tapestry.browser.nil?
  begin_with if respond_to?(:begin_with)
  instance_eval(&block) if block
end