bewildr 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/lib/bewildr/exceptions.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
2
|
|
3
|
-
|
4
|
-
class
|
5
|
-
class
|
6
|
-
class
|
7
|
-
class
|
8
|
-
class
|
9
|
-
|
10
|
-
class
|
3
|
+
module Bewildr
|
4
|
+
class ElementNotEnabled < StandardError; end
|
5
|
+
class ElementDoesntExist < StandardError; end
|
6
|
+
class PasswordFieldReadAttempt < StandardError; end
|
7
|
+
class NoSuchItemInComboBox < StandardError; end
|
8
|
+
class NoSuchItemInListBox < StandardError; end
|
9
|
+
class NoSuchTab < StandardError; end
|
10
|
+
class InternalError < StandardError; end
|
11
|
+
end
|
data/lib/bewildr/finder.rb
CHANGED
@@ -1,66 +1,66 @@
|
|
1
|
-
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
-
|
3
|
-
module Bewildr
|
4
|
-
class Finder
|
5
|
-
extend Bewildr::BewildrHelpers
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def condition_for(condition_hash)
|
9
|
-
conditions = condition_hash.select {|key, value| [:id, :name, :type].include?(key) }
|
10
|
-
conditions = Hash[*conditions.flatten]
|
11
|
-
case
|
12
|
-
when conditions.length == 0 then raise "Condition needs to include at least an :id, a :name or a :type"
|
13
|
-
when conditions.length == 1 then return single_condition(conditions)
|
14
|
-
when conditions.length > 1 then return multiple_conditions(conditions)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def scope_for(condition_hash)
|
19
|
-
case condition_hash[:scope]
|
20
|
-
when :children then System::Windows::Automation::TreeScope.Children
|
21
|
-
when :descendants, nil then System::Windows::Automation::TreeScope.Descendants
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
#returns the method to call
|
26
|
-
def how_many_for(condition_hash)
|
27
|
-
case condition_hash[:how_many]
|
28
|
-
when :first
|
29
|
-
when :all
|
30
|
-
else raise "Invalid number of elements to look for. Use ':first' or ':all'"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def multiple_conditions(condition_hash)
|
37
|
-
condition_array = []
|
38
|
-
condition_hash.keys.each {|key| condition_array << single_condition({key => condition_hash[key]}) }
|
39
|
-
System::Windows::Automation::AndCondition.new(r_array_to_cs_array_of_conditions(condition_array))
|
40
|
-
end
|
41
|
-
|
42
|
-
def single_condition(condition_hash)
|
43
|
-
case condition_hash.keys.first
|
44
|
-
when :id then id_condition(condition_hash)
|
45
|
-
when :name then name_condition(condition_hash)
|
46
|
-
when :type then type_condition(condition_hash)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def id_condition(condition_hash)
|
51
|
-
value = r_string_to_c_string(condition_hash[:id].to_s)
|
52
|
-
System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.automation_id_property, value)
|
53
|
-
end
|
54
|
-
|
55
|
-
def name_condition(condition_hash)
|
56
|
-
value = r_string_to_c_string(condition_hash[:name])
|
57
|
-
System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.name_property, value)
|
58
|
-
end
|
59
|
-
|
60
|
-
def type_condition(condition_hash)
|
61
|
-
value = Bewildr::ControlType.class_for_symbol(condition_hash[:type])
|
62
|
-
System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.control_type_property, value)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
1
|
+
#Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
|
2
|
+
|
3
|
+
module Bewildr
|
4
|
+
class Finder
|
5
|
+
extend Bewildr::BewildrHelpers
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def condition_for(condition_hash)
|
9
|
+
conditions = condition_hash.select {|key, value| [:id, :name, :type].include?(key) }
|
10
|
+
conditions = Hash[*conditions.flatten]
|
11
|
+
case
|
12
|
+
when conditions.length == 0 then raise "Condition needs to include at least an :id, a :name or a :type"
|
13
|
+
when conditions.length == 1 then return single_condition(conditions)
|
14
|
+
when conditions.length > 1 then return multiple_conditions(conditions)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def scope_for(condition_hash)
|
19
|
+
case condition_hash[:scope]
|
20
|
+
when :children then System::Windows::Automation::TreeScope.Children
|
21
|
+
when :descendants, nil then System::Windows::Automation::TreeScope.Descendants
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#returns the method to call
|
26
|
+
def how_many_for(condition_hash)
|
27
|
+
case condition_hash[:how_many]
|
28
|
+
when :first, nil then :find_first
|
29
|
+
when :all then :find_all
|
30
|
+
else raise "Invalid number of elements to look for. Use ':first' or ':all'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def multiple_conditions(condition_hash)
|
37
|
+
condition_array = []
|
38
|
+
condition_hash.keys.each {|key| condition_array << single_condition({key => condition_hash[key]}) }
|
39
|
+
System::Windows::Automation::AndCondition.new(r_array_to_cs_array_of_conditions(condition_array))
|
40
|
+
end
|
41
|
+
|
42
|
+
def single_condition(condition_hash)
|
43
|
+
case condition_hash.keys.first
|
44
|
+
when :id then id_condition(condition_hash)
|
45
|
+
when :name then name_condition(condition_hash)
|
46
|
+
when :type then type_condition(condition_hash)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def id_condition(condition_hash)
|
51
|
+
value = r_string_to_c_string(condition_hash[:id].to_s)
|
52
|
+
System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.automation_id_property, value)
|
53
|
+
end
|
54
|
+
|
55
|
+
def name_condition(condition_hash)
|
56
|
+
value = r_string_to_c_string(condition_hash[:name])
|
57
|
+
System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.name_property, value)
|
58
|
+
end
|
59
|
+
|
60
|
+
def type_condition(condition_hash)
|
61
|
+
value = Bewildr::ControlType.class_for_symbol(condition_hash[:type])
|
62
|
+
System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.control_type_property, value)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
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: 2010-
|
18
|
+
date: 2010-07-05 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/bewildr/control_patterns/range_value_pattern.rb
|
41
41
|
- lib/bewildr/control_patterns/selection_item_pattern.rb
|
42
42
|
- lib/bewildr/control_patterns/selection_pattern.rb
|
43
|
+
- lib/bewildr/control_patterns/table_item_pattern.rb
|
43
44
|
- lib/bewildr/control_patterns/table_pattern.rb
|
44
45
|
- lib/bewildr/control_patterns/text_pattern.rb
|
45
46
|
- lib/bewildr/control_patterns/toggle_pattern.rb
|