Module: Mohawk
- Extended by:
- Waiter
- Includes:
- Waiter
- Defined in:
- lib/mohawk.rb,
lib/mohawk/waiter.rb,
lib/mohawk/win_32.rb,
lib/mohawk/version.rb,
lib/mohawk/accessors.rb,
lib/mohawk/navigation.rb,
lib/mohawk/adapters/uia/radio.rb,
lib/mohawk/adapters/uia/table.rb,
lib/mohawk/adapters/uia/button.rb,
lib/mohawk/adapters/uia/window.rb,
lib/mohawk/adapters/uia/control.rb,
lib/mohawk/adapters/uia/spinner.rb,
lib/mohawk/adapters/uia_adapter.rb,
lib/mohawk/adapters/uia/checkbox.rb,
lib/mohawk/adapters/uia/text_box.rb,
lib/mohawk/adapters/uia/menu_item.rb,
lib/mohawk/adapters/uia/table_row.rb,
lib/mohawk/adapters/uia/tree_view.rb,
lib/mohawk/adapters/uia/select_list.rb,
lib/mohawk/adapters/uia/tab_control.rb,
lib/mohawk/adapters/uia/value_control.rb,
lib/mohawk/adapters/uia/element_locator.rb
Defined Under Namespace
Modules: Accessors, Adapters, Navigation, Waiter, Win32 Classes: InvalidApplicationPath
Constant Summary collapse
- VERSION =
'0.4.4'
Class Attribute Summary collapse
-
.default_adapter ⇒ Object
Returns the value of attribute default_adapter.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Class Method Summary collapse
- .app ⇒ Object
- .app_path=(path) ⇒ Object
- .included(cls) ⇒ Object
- .start(working_directory = nil) ⇒ Object
- .stop ⇒ Object
Instance Method Summary collapse
-
#active? ⇒ Boolean
Returns whether or not the window is active.
-
#exist? ⇒ Boolean
Returns whether or not the window exists.
-
#has_text?(text_to_find) ⇒ Boolean
Indicates if the window has text or not.
- #initialize(extra = {}) ⇒ Object
-
#present? ⇒ Boolean
Returns whether or not the window is present.
-
#wait_for_control(locator) ⇒ Object
Waits until a control exists.
-
#wait_until_present(context = nil) ⇒ Object
Waits until the window is present.
Methods included from Waiter
Class Attribute Details
.default_adapter ⇒ Object
Returns the value of attribute default_adapter.
52 53 54 |
# File 'lib/mohawk.rb', line 52 def default_adapter @default_adapter end |
.timeout ⇒ Object
Returns the value of attribute timeout.
51 52 53 |
# File 'lib/mohawk.rb', line 51 def timeout @timeout end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
25 26 27 |
# File 'lib/mohawk.rb', line 25 def adapter @adapter end |
Class Method Details
.app ⇒ Object
42 43 44 |
# File 'lib/mohawk.rb', line 42 def self.app @app end |
.app_path=(path) ⇒ Object
46 47 48 |
# File 'lib/mohawk.rb', line 46 def self.app_path=(path) @app_path = path end |
.included(cls) ⇒ Object
21 22 23 |
# File 'lib/mohawk.rb', line 21 def self.included(cls) cls.extend Mohawk::Accessors end |
.start(working_directory = nil) ⇒ Object
27 28 29 30 31 32 33 34 |
# 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 ⇒ Object
36 37 38 39 40 |
# 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 |
Instance Method Details
#active? ⇒ Boolean
Returns whether or not the window is active
80 81 82 |
# File 'lib/mohawk.rb', line 80 def active? adapter.window.active? end |
#exist? ⇒ Boolean
Returns whether or not the window exists
73 74 75 |
# File 'lib/mohawk.rb', line 73 def exist? adapter.window.exist? end |
#has_text?(text_to_find) ⇒ Boolean
Indicates if the window has text or not
113 114 115 |
# File 'lib/mohawk.rb', line 113 def has_text?(text_to_find) adapter.window.text.include? text_to_find end |
#initialize(extra = {}) ⇒ Object
64 65 66 67 68 |
# 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 |
#present? ⇒ Boolean
Returns whether or not the window is present
87 88 89 |
# File 'lib/mohawk.rb', line 87 def present? adapter.window.present? end |
#wait_for_control(locator) ⇒ Object
Waits until a control exists
101 102 103 104 105 106 107 108 |
# 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) ⇒ Object
Waits until the window is present
94 95 96 |
# File 'lib/mohawk.rb', line 94 def wait_until_present(context=nil) adapter.window.wait_until_present context end |