module Mohawk

Constants

VERSION

Attributes

default_adapter[RW]
timeout[RW]
adapter[R]

Public Class Methods

app() click to toggle source
# File lib/mohawk.rb, line 42
def self.app
  @app
end
app_path=(path) click to toggle source
# File lib/mohawk.rb, line 46
def self.app_path=(path)
  @app_path = path
end
default_adapter=(cls) click to toggle source
# File lib/mohawk.rb, line 60
def self.default_adapter=(cls)
  @default_adapter = cls
end
included(cls) click to toggle source
# File lib/mohawk.rb, line 21
def self.included(cls)
  cls.extend Mohawk::Accessors
end
new(extra={}) click to toggle source
# File lib/mohawk.rb, line 64
def initialize(extra={})
  locator = [which_window.merge(extra)]
  locator << parent_container if respond_to?(:parent_container)
  @adapter = Mohawk.default_adapter.new(*locator)
end
start(working_directory = nil) click to toggle source
# File lib/mohawk.rb, line 27
def self.start(working_directory = nil)
  raise InvalidApplicationPath.new unless @app_path
  @app = ChildProcess.build(@app_path)
  @app.cwd = working_directory if working_directory
  @app.start

  wait_until { Uia.find_element pid: @app.pid  }
end
stop() click to toggle source
# File lib/mohawk.rb, line 36
def self.stop
  raise 'An application was never started' unless @app
  @app.stop unless @app.exited?
  @app = nil
end

Public Instance Methods

active?() click to toggle source

Returns whether or not the window is active

# File lib/mohawk.rb, line 80
def active?
  adapter.window.active?
end
exist?() click to toggle source

Returns whether or not the window exists

# File lib/mohawk.rb, line 73
def exist?
  adapter.window.exist?
end
has_text?(text_to_find) click to toggle source

Indicates if the window has text or not

# File lib/mohawk.rb, line 113
def has_text?(text_to_find)
  adapter.window.text.include? text_to_find
end
present?() click to toggle source

Returns whether or not the window is present

# File lib/mohawk.rb, line 87
def present?
  adapter.window.present?
end
wait_for_control(locator) click to toggle source

Waits until a control exists

# File lib/mohawk.rb, line 101
def wait_for_control(locator)
  control = adapter.control(locator)
  begin
    wait_until { control.exist? }
  rescue
    raise "A control with #{locator} was not found"
  end
end
wait_until_present(context=nil) click to toggle source

Waits until the window is present

# File lib/mohawk.rb, line 94
def wait_until_present(context=nil)
  adapter.window.wait_until_present context
end