bewildr 0.1.11 → 0.1.12
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 +1 -1
- data/lib/bewildr/application.rb +2 -5
- data/lib/bewildr/control_type_additions/combo_box_additions.rb +3 -7
- data/lib/bewildr/control_type_additions/list_additions.rb +4 -9
- data/lib/bewildr/element.rb +15 -6
- data/lib/bewildr/finder.rb +1 -1
- data/lib/bewildr/mouse.rb +1 -1
- metadata +4 -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.12'
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
|
16
16
|
s.summary = 'Test WPF UI apps with IronRuby'
|
data/lib/bewildr/application.rb
CHANGED
@@ -63,13 +63,10 @@ module Bewildr
|
|
63
63
|
def wait_for_window(input, wait_time = 30)
|
64
64
|
begin
|
65
65
|
Timeout::timeout(wait_time) do
|
66
|
-
|
66
|
+
loop do
|
67
67
|
my_window = window(input)
|
68
|
-
|
69
|
-
return my_window
|
70
|
-
rescue
|
68
|
+
return my_window unless my_window.nil?
|
71
69
|
sleep 0.2
|
72
|
-
retry
|
73
70
|
end
|
74
71
|
end
|
75
72
|
rescue Timeout::Error
|
@@ -5,17 +5,14 @@ module Bewildr
|
|
5
5
|
module ComboBoxAdditions
|
6
6
|
#Returns a string array containing the element's item names
|
7
7
|
def items
|
8
|
-
|
9
|
-
return nil if my_list_items.nil?
|
10
|
-
my_list_items.collect {|item| item.name}
|
8
|
+
list_items.collect {|item| item.name}
|
11
9
|
end
|
12
10
|
|
13
11
|
#Returns an array containing the combobox items
|
14
12
|
def list_items
|
15
13
|
begin
|
16
14
|
expand_combo
|
17
|
-
|
18
|
-
bewildr_list_items.nil? ? nil : bewildr_list_items
|
15
|
+
get(:type => :list_item, :scope => :children, :how_many => :all)
|
19
16
|
ensure
|
20
17
|
collapse_combo
|
21
18
|
end
|
@@ -23,8 +20,7 @@ module Bewildr
|
|
23
20
|
|
24
21
|
#Returns the number of items in the combobox
|
25
22
|
def count
|
26
|
-
|
27
|
-
my_items.nil? ? 0 : my_items.size
|
23
|
+
items.size
|
28
24
|
end
|
29
25
|
|
30
26
|
#Selects a combobox item. Takes a string (and selects the first item whose name matches) or an integer and selects the respective element
|
@@ -5,28 +5,23 @@ module Bewildr
|
|
5
5
|
module ListAdditions
|
6
6
|
#Select the list item whose name matches the supplied input
|
7
7
|
def select(input)
|
8
|
-
|
9
|
-
selectable_elements.find {|selectable_element| selectable_element.name == input}.select
|
8
|
+
list_items.find {|selectable_element| selectable_element.name == input}.select
|
10
9
|
end
|
11
10
|
|
12
11
|
#Returns a string array containing the list item names
|
13
12
|
def items
|
14
|
-
|
15
|
-
return nil if my_list_items.nil?
|
16
|
-
my_list_items.collect {|item| item.name}
|
13
|
+
list_items.collect {|item| item.name}
|
17
14
|
end
|
18
15
|
|
19
16
|
#Returns an array containing the list items
|
20
17
|
def list_items
|
21
18
|
prepare_element
|
22
|
-
|
23
|
-
bewildr_list_items.nil? ? nil : bewildr_list_items
|
19
|
+
get(:type => :list_item, :scope => :children, :how_many => :all)
|
24
20
|
end
|
25
21
|
|
26
22
|
#Returns the number of items in the list
|
27
23
|
def count
|
28
|
-
|
29
|
-
my_items.nil? ? 0 : my_items.size
|
24
|
+
items.size
|
30
25
|
end
|
31
26
|
|
32
27
|
#Selects a list item. Takes a string (and selects the first item whose name matches) or an integer and selects the respective element
|
data/lib/bewildr/element.rb
CHANGED
@@ -107,12 +107,7 @@ module Bewildr
|
|
107
107
|
case result
|
108
108
|
when System::Windows::Automation::AutomationElement, nil then return Bewildr::Element.new(result)
|
109
109
|
when System::Windows::Automation::AutomationElementCollection
|
110
|
-
|
111
|
-
element_array = c_array_list.to_array.to_a
|
112
|
-
case
|
113
|
-
when element_array.size == 0 then return Bewildr::Element.new(nil)
|
114
|
-
when element_array.size > 0 then return element_array.collect {|element| Bewildr::Element.new(element) }
|
115
|
-
end
|
110
|
+
System::Collections::ArrayList.new(result).to_array.to_a.collect {|element| Bewildr::Element.new(element) }
|
116
111
|
end
|
117
112
|
end
|
118
113
|
|
@@ -148,6 +143,20 @@ module Bewildr
|
|
148
143
|
bewildred_children
|
149
144
|
end
|
150
145
|
|
146
|
+
#Returns the current element's next sibling, or nil if there is no next sibling
|
147
|
+
def next_sibling
|
148
|
+
walker = System::Windows::Automation::TreeWalker.ControlViewWalker
|
149
|
+
potential_next_sibling = walker.get_next_sibling(@automation_element)
|
150
|
+
potential_next_sibling.nil? ? nil : Bewildr::Element.new(potential_next_sibling)
|
151
|
+
end
|
152
|
+
|
153
|
+
#Returns the current element's previous sibling, or nil if there is no previous sibling
|
154
|
+
def previous_sibling
|
155
|
+
walker = System::Windows::Automation::TreeWalker.ControlViewWalker
|
156
|
+
potential_previous_sibling = walker.get_previous_sibling(@automation_element)
|
157
|
+
potential_previous_sibling.nil? ? nil : Bewildr::Element.new(potential_previous_sibling)
|
158
|
+
end
|
159
|
+
|
151
160
|
#Clicks this element - this is done by actual mouse moves and clicks. The automation element's underlying InvokePattern is not used.
|
152
161
|
def click
|
153
162
|
Bewildr::Mouse.click(clickable_point)
|
data/lib/bewildr/finder.rb
CHANGED
@@ -17,7 +17,7 @@ module Bewildr
|
|
17
17
|
#These keys can be combined to create more complex search criteria
|
18
18
|
def condition_for(condition_hash)
|
19
19
|
conditions = condition_hash.select {|key, value| [:id, :name, :type].include?(key) }
|
20
|
-
conditions = Hash[*conditions.flatten] if
|
20
|
+
conditions = Hash[*conditions.flatten] if conditions.instance_of?(Array) #if condition deals with ironruby's 1.8.6 emulation
|
21
21
|
|
22
22
|
case
|
23
23
|
when conditions.length == 0 then raise "Condition needs to include at least an :id, a :name or a :type"
|
data/lib/bewildr/mouse.rb
CHANGED
@@ -41,7 +41,7 @@ class Bewildr::Mouse
|
|
41
41
|
instance.clickr.set_location(point)
|
42
42
|
end
|
43
43
|
|
44
|
-
#Drags the mouse from one location to another, and optionally, via another! Pass a
|
44
|
+
#Drags the mouse from one location to another, and optionally, via another! Pass a hash containing the following keys:
|
45
45
|
# :from
|
46
46
|
# :to
|
47
47
|
# :via (optional)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bewildr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 12
|
10
|
+
version: 0.1.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nat Ritmeyer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-26 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|