bewildr 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -2
- data/lib/bewildr.rb +1 -0
- data/lib/bewildr/application.rb +2 -1
- data/lib/bewildr/control_patterns/grid_pattern.rb +5 -0
- data/lib/bewildr/control_patterns/invoke_pattern.rb +10 -10
- data/lib/bewildr/control_patterns/table_item_pattern.rb +15 -0
- data/lib/bewildr/control_patterns/table_pattern.rb +20 -17
- data/lib/bewildr/control_patterns/toggle_pattern.rb +1 -1
- data/lib/bewildr/control_patterns/value_pattern.rb +2 -1
- data/lib/bewildr/control_type_additions/combo_box_additions.rb +86 -86
- data/lib/bewildr/control_type_additions/data_grid_additions.rb +3 -1
- data/lib/bewildr/control_type_additions/list_additions.rb +57 -57
- data/lib/bewildr/control_type_additions/menu_additions.rb +64 -64
- data/lib/bewildr/control_type_additions/menu_item_additions.rb +18 -18
- data/lib/bewildr/control_type_additions/tab_additions.rb +31 -31
- data/lib/bewildr/control_type_additions/tree_additions.rb +3 -3
- data/lib/bewildr/element.rb +208 -189
- data/lib/bewildr/exceptions.rb +9 -8
- data/lib/bewildr/finder.rb +66 -66
- metadata +5 -4
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ require 'cucumber/rake/task'
|
|
10
10
|
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
12
|
s.name = 'bewildr'
|
13
|
-
s.version = '0.1.
|
13
|
+
s.version = '0.1.3'
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
|
16
16
|
s.summary = 'Test WPF UI apps with (iron) ruby!'
|
@@ -48,5 +48,5 @@ Spec::Rake::SpecTask.new do |t|
|
|
48
48
|
end
|
49
49
|
|
50
50
|
Cucumber::Rake::Task.new(:features) do |t|
|
51
|
-
t.cucumber_opts = "
|
51
|
+
t.cucumber_opts = "--format pretty -q"
|
52
52
|
end
|
data/lib/bewildr.rb
CHANGED
@@ -39,6 +39,7 @@ require 'bewildr/control_patterns/range_value_pattern'
|
|
39
39
|
require 'bewildr/control_patterns/grid_pattern'
|
40
40
|
require 'bewildr/control_patterns/table_pattern'
|
41
41
|
require 'bewildr/control_patterns/text_pattern'
|
42
|
+
require 'bewildr/control_patterns/table_item_pattern'
|
42
43
|
|
43
44
|
require 'bewildr/control_type_additions/text_additions'
|
44
45
|
require 'bewildr/control_type_additions/combo_box_additions'
|
data/lib/bewildr/application.rb
CHANGED
@@ -53,12 +53,13 @@ module Bewildr
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
rescue Timeout::Error
|
56
|
-
raise ElementDoesntExist
|
56
|
+
raise Bewildr::ElementDoesntExist
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
#takes name or full path of exe to start
|
61
61
|
def self.start(process_name)
|
62
|
+
raise "Can't find: #{process_name}" unless File.exist?(process_name)
|
62
63
|
Bewildr::Application.new(System::Diagnostics::Process.start(process_name))
|
63
64
|
end
|
64
65
|
|
@@ -10,6 +10,11 @@ module Bewildr
|
|
10
10
|
def column_count
|
11
11
|
@automation_element.get_current_pattern(System::Windows::Automation::GridPattern.pattern).current.column_count
|
12
12
|
end
|
13
|
+
|
14
|
+
def get_item(row, column)
|
15
|
+
item = @automation_element.get_current_pattern(System::Windows::Automation::GridPattern.pattern).get_item(row, column)
|
16
|
+
Bewildr::Element.new(item)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
-
|
3
|
-
module Bewildr
|
4
|
-
module ControlPatterns
|
5
|
-
module InvokePattern
|
6
|
-
def click
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlPatterns
|
5
|
+
module InvokePattern
|
6
|
+
def click
|
7
|
+
@automation_element.get_current_pattern(System::Windows::Automation::InvokePattern.pattern).invoke
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlPatterns
|
5
|
+
module TableItemPattern
|
6
|
+
def row_span
|
7
|
+
@automation_element.get_current_pattern(System::Windows::Automation::TableItemPattern.pattern).current.row_span.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def column_span
|
11
|
+
@automation_element.get_current_pattern(System::Windows::Automation::TableItemPattern.pattern).current.column_span.to_i
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,17 +1,20 @@
|
|
1
|
-
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
-
|
3
|
-
module Bewildr
|
4
|
-
module ControlPatterns
|
5
|
-
module TablePattern
|
6
|
-
def column_headers
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlPatterns
|
5
|
+
module TablePattern
|
6
|
+
def column_headers
|
7
|
+
#the following line seems to prompt the table pattern into giving up the column header
|
8
|
+
#information that's called on the line that follows it. Weird? tell me about it...
|
9
|
+
@automation_element.get_current_pattern(System::Windows::Automation::TablePattern.pattern).current.get_row_headers
|
10
|
+
@automation_element.get_current_pattern(System::Windows::Automation::TablePattern.pattern).current.get_column_headers.collect do |header|
|
11
|
+
Bewildr::Element.new(header)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def column_header_names
|
16
|
+
column_headers.collect {|header| header.name }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -50,7 +50,7 @@ module Bewildr
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def set_state_to(value)
|
53
|
-
raise ElementNotEnabled unless enabled?
|
53
|
+
raise Bewildr::ElementNotEnabled unless enabled?
|
54
54
|
case value
|
55
55
|
when :on then flip_state while state != :on
|
56
56
|
when :off then flip_state while state != :off
|
@@ -8,11 +8,12 @@ module Bewildr
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def text
|
11
|
-
raise PasswordFieldReadAttempt, "You can't get the text of a password field" if is_password_field?
|
11
|
+
raise Bewildr::PasswordFieldReadAttempt, "You can't get the text of a password field" if is_password_field?
|
12
12
|
@automation_element.get_current_pattern(System::Windows::Automation::ValuePattern.pattern).current.value.to_s
|
13
13
|
end
|
14
14
|
|
15
15
|
def text=(input)
|
16
|
+
raise Bewildr::ElementNotEnabled unless enabled?
|
16
17
|
@automation_element.get_current_pattern(System::Windows::Automation::ValuePattern.pattern).set_value(input)
|
17
18
|
end
|
18
19
|
end
|
@@ -1,87 +1,87 @@
|
|
1
|
-
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
-
|
3
|
-
module Bewildr
|
4
|
-
module ControlTypeAdditions
|
5
|
-
module ComboBoxAdditions
|
6
|
-
def self.extended(base)
|
7
|
-
base.extend Bewildr::ControlPatterns::ExpandCollapsePattern
|
8
|
-
base.extend Bewildr::ControlPatterns::SelectionPattern
|
9
|
-
base.extend Bewildr::ControlPatterns::SelectionItemPattern
|
10
|
-
|
11
|
-
base.instance_eval do
|
12
|
-
def items
|
13
|
-
my_list_items = list_items
|
14
|
-
return nil if my_list_items.nil?
|
15
|
-
my_list_items.collect {|item| item.name}
|
16
|
-
end
|
17
|
-
|
18
|
-
def list_items
|
19
|
-
begin
|
20
|
-
expand_combo
|
21
|
-
bewildr_list_items = get(:type => :list_item, :scope => :children)
|
22
|
-
bewildr_list_items.nil? ? nil : bewildr_list_items
|
23
|
-
ensure
|
24
|
-
collapse_combo
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def count
|
29
|
-
my_items = items
|
30
|
-
my_items.nil? ? 0 : my_items.size
|
31
|
-
end
|
32
|
-
|
33
|
-
def select(input)
|
34
|
-
case input
|
35
|
-
when String then select_by_name(input)
|
36
|
-
when Integer then select_by_index(input)
|
37
|
-
else raise ArgumentError, "Select by name or by index"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def select_by_name(input)
|
42
|
-
begin
|
43
|
-
expand_combo
|
44
|
-
my_item = list_items.find {|item| item.name == input}
|
45
|
-
raise NoSuchItemInComboBox if my_item.nil?
|
46
|
-
my_item.select
|
47
|
-
ensure
|
48
|
-
collapse_combo
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def select_by_index(input)
|
53
|
-
raise "Index must be 0 or greater" if input < 0
|
54
|
-
begin
|
55
|
-
expand_combo
|
56
|
-
my_item = list_items[input].select
|
57
|
-
ensure
|
58
|
-
collapse_combo
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def selected
|
63
|
-
#TODO: find a way to not need to expand and collapse before getting the selected item
|
64
|
-
expand_combo
|
65
|
-
collapse_combo
|
66
|
-
#get_selection.first
|
67
|
-
get_selection.first.name
|
68
|
-
end
|
69
|
-
|
70
|
-
def expand_combo
|
71
|
-
expand
|
72
|
-
Timeout.timeout(30) do
|
73
|
-
sleep 0.2 until expand_state == :expanded
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def collapse_combo
|
78
|
-
collapse
|
79
|
-
Timeout.timeout(30) do
|
80
|
-
sleep 0.2 until expand_state == :collapsed
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlTypeAdditions
|
5
|
+
module ComboBoxAdditions
|
6
|
+
def self.extended(base)
|
7
|
+
base.extend Bewildr::ControlPatterns::ExpandCollapsePattern
|
8
|
+
base.extend Bewildr::ControlPatterns::SelectionPattern
|
9
|
+
base.extend Bewildr::ControlPatterns::SelectionItemPattern
|
10
|
+
|
11
|
+
base.instance_eval do
|
12
|
+
def items
|
13
|
+
my_list_items = list_items
|
14
|
+
return nil if my_list_items.nil?
|
15
|
+
my_list_items.collect {|item| item.name}
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_items
|
19
|
+
begin
|
20
|
+
expand_combo
|
21
|
+
bewildr_list_items = get(:type => :list_item, :scope => :children, :how_many => :all)
|
22
|
+
bewildr_list_items.nil? ? nil : bewildr_list_items
|
23
|
+
ensure
|
24
|
+
collapse_combo
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def count
|
29
|
+
my_items = items
|
30
|
+
my_items.nil? ? 0 : my_items.size
|
31
|
+
end
|
32
|
+
|
33
|
+
def select(input)
|
34
|
+
case input
|
35
|
+
when String then select_by_name(input)
|
36
|
+
when Integer then select_by_index(input)
|
37
|
+
else raise ArgumentError, "Select by name or by index"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def select_by_name(input)
|
42
|
+
begin
|
43
|
+
expand_combo
|
44
|
+
my_item = list_items.find {|item| item.name == input}
|
45
|
+
raise Bewildr::NoSuchItemInComboBox if my_item.nil?
|
46
|
+
my_item.select
|
47
|
+
ensure
|
48
|
+
collapse_combo
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def select_by_index(input)
|
53
|
+
raise "Index must be 0 or greater" if input < 0
|
54
|
+
begin
|
55
|
+
expand_combo
|
56
|
+
my_item = list_items[input].select
|
57
|
+
ensure
|
58
|
+
collapse_combo
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def selected
|
63
|
+
#TODO: find a way to not need to expand and collapse before getting the selected item
|
64
|
+
expand_combo
|
65
|
+
collapse_combo
|
66
|
+
#get_selection.first
|
67
|
+
get_selection.first.name
|
68
|
+
end
|
69
|
+
|
70
|
+
def expand_combo
|
71
|
+
expand
|
72
|
+
Timeout.timeout(30) do
|
73
|
+
sleep 0.2 until expand_state == :expanded
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def collapse_combo
|
78
|
+
collapse
|
79
|
+
Timeout.timeout(30) do
|
80
|
+
sleep 0.2 until expand_state == :collapsed
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
87
|
end
|
@@ -1,57 +1,57 @@
|
|
1
|
-
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
-
|
3
|
-
module Bewildr
|
4
|
-
module ControlTypeAdditions
|
5
|
-
module ListAdditions
|
6
|
-
def self.extended(base)
|
7
|
-
base.extend Bewildr::ControlPatterns::SelectionPattern
|
8
|
-
|
9
|
-
base.instance_eval do
|
10
|
-
def select(input)
|
11
|
-
selectable_elements = get(:type => :list_item, :scope => :children)
|
12
|
-
selectable_elements.find {|selectable_element| selectable_element.name == input}.select
|
13
|
-
end
|
14
|
-
|
15
|
-
def items
|
16
|
-
my_list_items = list_items
|
17
|
-
return nil if my_list_items.nil?
|
18
|
-
my_list_items.collect {|item| item.name}
|
19
|
-
end
|
20
|
-
|
21
|
-
def list_items
|
22
|
-
bewildr_list_items = get(:type => :list_item, :scope => :children)
|
23
|
-
bewildr_list_items.nil? ? nil : bewildr_list_items
|
24
|
-
end
|
25
|
-
|
26
|
-
def count
|
27
|
-
my_items = items
|
28
|
-
my_items.nil? ? 0 : my_items.size
|
29
|
-
end
|
30
|
-
|
31
|
-
def select(input)
|
32
|
-
case input
|
33
|
-
when String then select_by_name(input)
|
34
|
-
when Integer then select_by_index(input)
|
35
|
-
else raise ArgumentError, "Select by name or by index"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def select_by_name(input)
|
40
|
-
my_item = list_items.find {|item| item.name == input}
|
41
|
-
raise NoSuchItemInListBox if my_item.nil?
|
42
|
-
my_item.select
|
43
|
-
end
|
44
|
-
|
45
|
-
def select_by_index(input)
|
46
|
-
raise "Index must be 0 or greater" if input < 0
|
47
|
-
my_item = list_items[input].select
|
48
|
-
end
|
49
|
-
|
50
|
-
def selected
|
51
|
-
get_selection.first.name
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
module ControlTypeAdditions
|
5
|
+
module ListAdditions
|
6
|
+
def self.extended(base)
|
7
|
+
base.extend Bewildr::ControlPatterns::SelectionPattern
|
8
|
+
|
9
|
+
base.instance_eval do
|
10
|
+
def select(input)
|
11
|
+
selectable_elements = get(:type => :list_item, :scope => :children, :how_many => :all)
|
12
|
+
selectable_elements.find {|selectable_element| selectable_element.name == input}.select
|
13
|
+
end
|
14
|
+
|
15
|
+
def items
|
16
|
+
my_list_items = list_items
|
17
|
+
return nil if my_list_items.nil?
|
18
|
+
my_list_items.collect {|item| item.name}
|
19
|
+
end
|
20
|
+
|
21
|
+
def list_items
|
22
|
+
bewildr_list_items = get(:type => :list_item, :scope => :children, :how_many => :all)
|
23
|
+
bewildr_list_items.nil? ? nil : bewildr_list_items
|
24
|
+
end
|
25
|
+
|
26
|
+
def count
|
27
|
+
my_items = items
|
28
|
+
my_items.nil? ? 0 : my_items.size
|
29
|
+
end
|
30
|
+
|
31
|
+
def select(input)
|
32
|
+
case input
|
33
|
+
when String then select_by_name(input)
|
34
|
+
when Integer then select_by_index(input)
|
35
|
+
else raise ArgumentError, "Select by name or by index"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def select_by_name(input)
|
40
|
+
my_item = list_items.find {|item| item.name == input}
|
41
|
+
raise Bewildr::NoSuchItemInListBox if my_item.nil?
|
42
|
+
my_item.select
|
43
|
+
end
|
44
|
+
|
45
|
+
def select_by_index(input)
|
46
|
+
raise "Index must be 0 or greater" if input < 0
|
47
|
+
my_item = list_items[input].select
|
48
|
+
end
|
49
|
+
|
50
|
+
def selected
|
51
|
+
get_selection.first.name
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|