mohawk 0.4.3 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/features/step_definitions/table_steps.rb +2 -2
- data/features/support/WindowsForms.exe +0 -0
- data/features/support/WindowsForms.exe.config +6 -0
- data/lib/mohawk/accessors.rb +57 -23
- data/lib/mohawk/adapters/uia/button.rb +2 -0
- data/lib/mohawk/adapters/uia/combo_box.rb +58 -0
- data/lib/mohawk/adapters/uia_adapter.rb +4 -0
- data/lib/mohawk/version.rb +1 -1
- data/mohawk.gemspec +3 -3
- data/spec/lib/mohawk/combo_box_spec.rb +14 -6
- data/spec/lib/mohawk/window_spec.rb +7 -4
- metadata +17 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f4d2928187d326a0466a236d0f7ef8fd9e87540eae09307991f979b1f629bca
|
4
|
+
data.tar.gz: 49c6314e0a4d35df36c6269477fe757c6ea78af19aad43e2c2a3a84f81102142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b549539d638f68b7259415772e87a49e86b714bb7e62d90e4774994b00a13519af5517235e62f29f4eb02dde37ae83f09ce19ff92c56e2bdf1a62dfb0036bf4
|
7
|
+
data.tar.gz: 1c9f4b2d339b75f188fdb8192d20ec2c1c5086a6f06ebd4bec4de758a7d7c6e835ce45bff6fca8e5b1113f5d6e90f09233458f373cc9b568d7d5ef292474dc26
|
@@ -4,8 +4,8 @@ When /^we are observing the people table$/ do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
Then /^the table row information should look like the following:$/ do |row_items|
|
7
|
-
row_items.map_column
|
8
|
-
row_items.map_headers
|
7
|
+
row_items = row_items.map_column("row") { |r| r.to_i }
|
8
|
+
row_items = row_items.map_headers("text" => :text, "row" => :row)
|
9
9
|
on(DataEntryForm).people.map(&:to_hash).should eq row_items.hashes
|
10
10
|
end
|
11
11
|
|
Binary file
|
data/lib/mohawk/accessors.rb
CHANGED
@@ -52,7 +52,7 @@ module Mohawk
|
|
52
52
|
# text(:first_name, :id => 'textFieldId')
|
53
53
|
# # will generate 'first_name', 'first_name=' and 'clear_first_name' methods
|
54
54
|
#
|
55
|
-
# @param [String]
|
55
|
+
# @param [String] name used for the generated methods
|
56
56
|
# @param [Hash] locator for how the text is found
|
57
57
|
#
|
58
58
|
def text(name, locator)
|
@@ -81,7 +81,7 @@ module Mohawk
|
|
81
81
|
# button(:close, :value => '&Close')
|
82
82
|
# # will generate 'close' and 'close_value' methods
|
83
83
|
#
|
84
|
-
# @param [String]
|
84
|
+
# @param [String] name used for the generated methods
|
85
85
|
# @param [Hash] locator for how the button is found
|
86
86
|
#
|
87
87
|
def button(name, locator)
|
@@ -102,37 +102,70 @@ module Mohawk
|
|
102
102
|
#
|
103
103
|
# @example
|
104
104
|
# combo_box(:status, :id => 'statusComboBox')
|
105
|
-
# # will generate 'status', '
|
105
|
+
# # will generate 'status', 'status=', 'select_status', and 'status_options' methods
|
106
106
|
#
|
107
|
-
# @param [String]
|
107
|
+
# @param [String] name used for the generated methods
|
108
108
|
# @param [Hash] locator for how the combo box is found
|
109
109
|
#
|
110
110
|
# === Aliases
|
111
111
|
# * combobox
|
112
112
|
# * dropdown / drop_down
|
113
|
-
|
113
|
+
|
114
114
|
#
|
115
115
|
def combo_box(name, locator)
|
116
116
|
define_method("#{name}") do
|
117
117
|
adapter.combo(locator).value
|
118
118
|
end
|
119
|
+
|
120
|
+
define_method("#{name}=") do |item|
|
121
|
+
adapter.combo(locator).with(:combo_box).set item
|
122
|
+
end
|
123
|
+
alias_method "select_#{name}", "#{name}="
|
124
|
+
|
125
|
+
define_method("#{name}_options") do
|
126
|
+
adapter.combo(locator).options
|
127
|
+
end
|
128
|
+
define_method("#{name}_view") do
|
129
|
+
adapter.combo(locator).view
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Generates methods to get the value of a list box, set the selected
|
135
|
+
# item by both index and value as well as to see the available options
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
# select_list(:status, :id => 'statusListBox')
|
139
|
+
# # will generate 'status', 'status_selections', 'status=', 'select_status','clear_status' and 'status_options' methods
|
140
|
+
#
|
141
|
+
# @param [String] name used for the generated methods
|
142
|
+
# @param [Hash] locator for how the list box is found
|
143
|
+
#
|
144
|
+
# === Aliases
|
145
|
+
# * selectlist
|
146
|
+
# * list_box
|
147
|
+
#
|
148
|
+
def select_list(name, locator)
|
149
|
+
define_method("#{name}") do
|
150
|
+
adapter.select_list(locator).value
|
151
|
+
end
|
119
152
|
define_method("clear_#{name}") do |item|
|
120
|
-
adapter.
|
153
|
+
adapter.select_list(locator).clear item
|
121
154
|
end
|
122
155
|
define_method("#{name}_selections") do
|
123
|
-
adapter.
|
156
|
+
adapter.select_list(locator).values
|
124
157
|
end
|
125
158
|
|
126
159
|
define_method("#{name}=") do |item|
|
127
|
-
adapter.
|
160
|
+
adapter.select_list(locator).set item
|
128
161
|
end
|
129
162
|
alias_method "select_#{name}", "#{name}="
|
130
163
|
|
131
164
|
define_method("#{name}_options") do
|
132
|
-
adapter.
|
165
|
+
adapter.select_list(locator).options
|
133
166
|
end
|
134
167
|
define_method("#{name}_view") do
|
135
|
-
adapter.
|
168
|
+
adapter.select_list(locator).view
|
136
169
|
end
|
137
170
|
end
|
138
171
|
|
@@ -144,7 +177,7 @@ module Mohawk
|
|
144
177
|
# checkbox(:include, :id => 'checkBoxId')
|
145
178
|
# # will generate 'include', 'include=' and 'include_value' methods
|
146
179
|
#
|
147
|
-
# @param [String]
|
180
|
+
# @param [String] name used for the generated methods
|
148
181
|
# @param [Hash] locator for how the checkbox is found
|
149
182
|
#
|
150
183
|
def checkbox(name, locator)
|
@@ -170,7 +203,7 @@ module Mohawk
|
|
170
203
|
# radio(:morning, :id => 'morningRadio')
|
171
204
|
# # will generate 'morning' and 'morning?' methods
|
172
205
|
#
|
173
|
-
# @param [String]
|
206
|
+
# @param [String] name used for the generated methods
|
174
207
|
# @param [Hash] locator for how the radio is found
|
175
208
|
#
|
176
209
|
def radio(name, locator)
|
@@ -192,7 +225,7 @@ module Mohawk
|
|
192
225
|
# label(:login_info, :id => 'loginInfoLabel')
|
193
226
|
# # will generate a 'login_info' method
|
194
227
|
#
|
195
|
-
# @param [String]
|
228
|
+
# @param [String] name used for the generated methods
|
196
229
|
# @param [Hash] locator for how the label is found
|
197
230
|
#
|
198
231
|
def label(name, locator)
|
@@ -211,7 +244,7 @@ module Mohawk
|
|
211
244
|
# link(:send_info_link, :id => 'sendInfoId')
|
212
245
|
# # will generate 'send_info_link_text' and 'click_send_info_link' methods
|
213
246
|
#
|
214
|
-
# @param [String]
|
247
|
+
# @param [String] name used for the generated methods
|
215
248
|
# @param [Hash] locator for how the label is found
|
216
249
|
#
|
217
250
|
def link(name, locator)
|
@@ -232,16 +265,14 @@ module Mohawk
|
|
232
265
|
# menu_item(:some_menu_item, :path => ["Path", "To", "A", "Menu Item"])
|
233
266
|
# # will generate a 'some_menu_item' method to select a menu item
|
234
267
|
#
|
235
|
-
# @param [String]
|
268
|
+
# @param [String] name used for the generated methods
|
236
269
|
# @param [Hash] locator for how the label is found
|
237
270
|
#
|
238
271
|
def menu_item(name, locator)
|
239
|
-
define_method("#{name}") do
|
240
|
-
adapter.menu_item(locator).select
|
241
|
-
end
|
242
272
|
define_method("click_#{name}") do
|
243
273
|
adapter.menu_item(locator).click
|
244
274
|
end
|
275
|
+
alias_method "#{name}", "click_#{name}"
|
245
276
|
end
|
246
277
|
|
247
278
|
# Generates methods for working with table or list view controls
|
@@ -252,7 +283,7 @@ module Mohawk
|
|
252
283
|
# # find_some_table and 'some_table_view' methods to get an Enumerable of table rows,
|
253
284
|
# # select a table item, clear a table item, return all of the headers and get the raw view
|
254
285
|
#
|
255
|
-
# @param [String]
|
286
|
+
# @param [String] name used for the generated methods
|
256
287
|
# @param [Hash] locator for how the label is found
|
257
288
|
#
|
258
289
|
# === Aliases
|
@@ -294,7 +325,7 @@ module Mohawk
|
|
294
325
|
# # methods to get the tree value, set the tree value (index or string), get all of the
|
295
326
|
# # items, expand an item (index or string) and collapse an item (index or string)
|
296
327
|
#
|
297
|
-
# @param [String]
|
328
|
+
# @param [String] name used for the generated methods
|
298
329
|
# @param [Hash] locator for how the label is found
|
299
330
|
#
|
300
331
|
# === Aliases
|
@@ -329,7 +360,7 @@ module Mohawk
|
|
329
360
|
# # will generate 'age', 'age=' methods to get the spinner value and
|
330
361
|
# # set the spinner value.
|
331
362
|
#
|
332
|
-
# @param [String]
|
363
|
+
# @param [String] name used for the generated methods
|
333
364
|
# @param [Hash] locator for how the spinner control is found
|
334
365
|
#
|
335
366
|
def spinner(name, locator)
|
@@ -358,7 +389,7 @@ module Mohawk
|
|
358
389
|
# # set the currently selected tab (Fixnum, String or RegEx) and to get the
|
359
390
|
# # available tabs to be selected
|
360
391
|
#
|
361
|
-
# @param [String]
|
392
|
+
# @param [String] name used for the generated methods
|
362
393
|
# @param [Hash] locator for how the tab control is found
|
363
394
|
#
|
364
395
|
def tabs(name, locator)
|
@@ -395,7 +426,10 @@ module Mohawk
|
|
395
426
|
alias_method :combobox, :combo_box
|
396
427
|
alias_method :dropdown, :combo_box
|
397
428
|
alias_method :drop_down, :combo_box
|
398
|
-
|
429
|
+
|
430
|
+
# select_list aliases
|
431
|
+
alias_method :selectlist, :select_list
|
432
|
+
alias_method :list_box, :select_list
|
399
433
|
|
400
434
|
# table aliases
|
401
435
|
alias_method :listview, :table
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative 'value_control'
|
2
|
+
require_relative 'element_locator'
|
3
|
+
|
4
|
+
module Mohawk
|
5
|
+
module Adapters
|
6
|
+
module UIA
|
7
|
+
class ComboBoxControl < ValueControl
|
8
|
+
include ElementLocator
|
9
|
+
|
10
|
+
alias_method :ctrl_element, :element
|
11
|
+
|
12
|
+
def value
|
13
|
+
if supports_selection?
|
14
|
+
selection_pattern.selected_items.map(&:name).first || ''
|
15
|
+
else
|
16
|
+
value_pattern.value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def options
|
21
|
+
if supports_selection?
|
22
|
+
all_items.map &:name
|
23
|
+
else
|
24
|
+
element.items.map &:name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def all_items
|
31
|
+
selection_pattern.selection_items
|
32
|
+
end
|
33
|
+
|
34
|
+
def click_or_select(item)
|
35
|
+
item.click
|
36
|
+
rescue
|
37
|
+
item.select
|
38
|
+
end
|
39
|
+
|
40
|
+
def selection_pattern
|
41
|
+
element.as :selection
|
42
|
+
end
|
43
|
+
|
44
|
+
def supports_selection?
|
45
|
+
selection_pattern
|
46
|
+
true
|
47
|
+
rescue
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def element
|
53
|
+
ctrl_element.with(:combo_box)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/mohawk/version.rb
CHANGED
data/mohawk.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency 'uia', '~> 0
|
22
|
-
gem.add_dependency 'require_all'
|
21
|
+
gem.add_dependency 'uia', '~> 1.0'
|
22
|
+
gem.add_dependency 'require_all', '~> 3.0'
|
23
23
|
gem.add_dependency 'page_navigation', '>= 0.7'
|
24
24
|
gem.add_dependency 'childprocess', '~> 0.5'
|
25
25
|
|
@@ -32,5 +32,5 @@ Gem::Specification.new do |gem|
|
|
32
32
|
gem.add_development_dependency 'guard'
|
33
33
|
gem.add_development_dependency 'guard-rspec'
|
34
34
|
gem.add_development_dependency 'terminal-notifier-guard'
|
35
|
-
gem.add_development_dependency 'json', '~> 2.1
|
35
|
+
gem.add_development_dependency 'json', '~> 2.1'
|
36
36
|
end
|
@@ -19,6 +19,14 @@ describe 'combo boxes' do
|
|
19
19
|
Then { main_form.fruits == 'Orange' }
|
20
20
|
end
|
21
21
|
|
22
|
+
context '#options' do
|
23
|
+
Then { main_form.fruits_options == ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"] }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'list boxes' do
|
28
|
+
Given(:main_form) { start_app }
|
29
|
+
|
22
30
|
context 'multi-select' do
|
23
31
|
Given { main_form.toggle_multi }
|
24
32
|
When { (0..2).each {|n| main_form.select_fruits_list n } }
|
@@ -42,11 +50,11 @@ describe 'combo boxes' do
|
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|
45
|
-
end
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
context 'events' do
|
55
|
+
# ListBox controls are special with regard to raising events
|
56
|
+
When { main_form.fruits_list = 'Orange' }
|
57
|
+
Then { main_form.fruits_label == 'Orange' }
|
58
|
+
end
|
51
59
|
end
|
52
|
-
end
|
60
|
+
end
|
@@ -11,11 +11,11 @@ describe Mohawk::Adapters::UIA::Window do
|
|
11
11
|
on(Class.new do
|
12
12
|
include Mohawk
|
13
13
|
window(title: /MainForm/)
|
14
|
-
parent(id: '
|
14
|
+
parent(id: 'groupBox2')
|
15
15
|
end)
|
16
16
|
end
|
17
17
|
|
18
|
-
Then { container.adapter.window.title == '
|
18
|
+
Then { container.adapter.window.title == 'Drop down list' }
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'children_only' do
|
@@ -34,7 +34,10 @@ describe Mohawk::Adapters::UIA::Window do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context '#active?' do
|
37
|
-
Then
|
37
|
+
Then do
|
38
|
+
not_created_form.exist?
|
39
|
+
expect(not_created_form.active?).to eq(false)
|
40
|
+
end
|
38
41
|
Then { main_form.active? == true }
|
39
42
|
|
40
43
|
context 'inactive --> active' do
|
@@ -81,4 +84,4 @@ describe Mohawk::Adapters::UIA::Window do
|
|
81
84
|
context '#wait_for_control' do
|
82
85
|
Then { main_form.wait_for_control value: 'Data Entry Form' }
|
83
86
|
end
|
84
|
-
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mohawk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Levi Wilson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uia
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: require_all
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: page_navigation
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 2.1
|
201
|
+
version: '2.1'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 2.1
|
208
|
+
version: '2.1'
|
209
209
|
description: Mohawk is a page-object style driver that makes it easy to automate windows
|
210
210
|
applications. It allows you to create a very flexible, clean and natural DSL around
|
211
211
|
whatever windows application that you are trying to automate using the RAutomation
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- features/support/FizzWare.NBuilder.dll
|
231
231
|
- features/support/UIA.Extensions.dll
|
232
232
|
- features/support/WindowsForms.exe
|
233
|
+
- features/support/WindowsForms.exe.config
|
233
234
|
- features/support/app/WindowsForms/WindowsForms.sln
|
234
235
|
- features/support/app/WindowsForms/WindowsForms/AboutBox.Designer.cs
|
235
236
|
- features/support/app/WindowsForms/WindowsForms/AboutBox.cs
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- lib/mohawk/accessors.rb
|
268
269
|
- lib/mohawk/adapters/uia/button.rb
|
269
270
|
- lib/mohawk/adapters/uia/checkbox.rb
|
271
|
+
- lib/mohawk/adapters/uia/combo_box.rb
|
270
272
|
- lib/mohawk/adapters/uia/control.rb
|
271
273
|
- lib/mohawk/adapters/uia/element_locator.rb
|
272
274
|
- lib/mohawk/adapters/uia/menu_item.rb
|
@@ -314,7 +316,7 @@ homepage: http://github.com/leviwilson/mohawk
|
|
314
316
|
licenses:
|
315
317
|
- MIT
|
316
318
|
metadata: {}
|
317
|
-
post_install_message:
|
319
|
+
post_install_message:
|
318
320
|
rdoc_options: []
|
319
321
|
require_paths:
|
320
322
|
- lib
|
@@ -329,9 +331,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
331
|
- !ruby/object:Gem::Version
|
330
332
|
version: '0'
|
331
333
|
requirements: []
|
332
|
-
|
333
|
-
|
334
|
-
signing_key:
|
334
|
+
rubygems_version: 3.2.32
|
335
|
+
signing_key:
|
335
336
|
specification_version: 4
|
336
337
|
summary: Provides a page-object style driver for automating Windows applications
|
337
338
|
test_files:
|
@@ -339,6 +340,7 @@ test_files:
|
|
339
340
|
- features/support/FizzWare.NBuilder.dll
|
340
341
|
- features/support/UIA.Extensions.dll
|
341
342
|
- features/support/WindowsForms.exe
|
343
|
+
- features/support/WindowsForms.exe.config
|
342
344
|
- features/support/app/WindowsForms/WindowsForms.sln
|
343
345
|
- features/support/app/WindowsForms/WindowsForms/AboutBox.Designer.cs
|
344
346
|
- features/support/app/WindowsForms/WindowsForms/AboutBox.cs
|