uia 0.0.7.1 → 0.0.7.2

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/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.0.7.2 / 2013-11-02
2
+ * Enhancements
3
+ * Element#find can specify the scope of the search
4
+
1
5
  === Version 0.0.7.1 / 2013-11-01
2
6
  * Bug Fixes
3
7
  * Fixes issue with ComboBox controls for Selection#selection_items
@@ -97,9 +97,9 @@ namespace UIA.Helper
97
97
  return FindFirst(automationId.IdCondition());
98
98
  }
99
99
 
100
- public Element ChildById(string automationId)
100
+ public Element ChildById(string automationId, TreeScope scope)
101
101
  {
102
- return FindFirst(TreeScope.Descendants, automationId.IdCondition());
102
+ return FindFirst(scope, automationId.IdCondition());
103
103
  }
104
104
 
105
105
  public static Element ByName(string name)
@@ -107,9 +107,9 @@ namespace UIA.Helper
107
107
  return FindFirst(new PropertyCondition(AutomationElement.NameProperty, name));
108
108
  }
109
109
 
110
- public Element ChildByName(string name)
110
+ public Element ChildByName(string name, TreeScope scope)
111
111
  {
112
- return FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, name));
112
+ return FindFirst(scope, new PropertyCondition(AutomationElement.NameProperty, name));
113
113
  }
114
114
 
115
115
  public static Element ByProcessId(int processId)
@@ -37,9 +37,10 @@ extern "C" {
37
37
  return NULL;
38
38
  }
39
39
 
40
- __declspec(dllexport) ElementInformationPtr Element_FindChildById(ElementInformationPtr parent, const char* automationId, char* errorInfo, const int errorLength) {
40
+ __declspec(dllexport) ElementInformationPtr Element_FindChildById(ElementInformationPtr parent, const char* automationId, const char* treeScope, char* errorInfo, const int errorLength) {
41
41
  try {
42
- return ElementInformation::From(Find(parent)->ChildById(gcnew String(automationId)));
42
+ auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope));
43
+ return ElementInformation::From(Find(parent)->ChildById(gcnew String(automationId), scope));
43
44
  } catch(Exception^ error) {
44
45
  StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
45
46
  }
@@ -57,9 +58,10 @@ extern "C" {
57
58
  return NULL;
58
59
  }
59
60
 
60
- __declspec(dllexport) ElementInformationPtr Element_FindChildByName(ElementInformationPtr parent, const char* name, char* errorInfo, const int errorLength) {
61
+ __declspec(dllexport) ElementInformationPtr Element_FindChildByName(ElementInformationPtr parent, const char* name, const char* treeScope, char* errorInfo, const int errorLength) {
61
62
  try {
62
- return ElementInformation::From(Find(parent)->ChildByName(gcnew String(name)));
63
+ auto scope = (TreeScope) Enum::Parse(TreeScope::typeid, gcnew String(treeScope));
64
+ return ElementInformation::From(Find(parent)->ChildByName(gcnew String(name), scope));
63
65
  } catch(Exception^ error) {
64
66
  StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
65
67
  }
data/lib/uia/element.rb CHANGED
@@ -27,11 +27,13 @@ module Uia
27
27
  end
28
28
 
29
29
  def find(locator)
30
+ scope = (locator[:scope] || :descendants).to_s.capitalize
31
+
30
32
  case
31
33
  when locator[:id]
32
- Library::find_child_by_id(@element, locator[:id])
34
+ Library::find_child_by_id(@element, locator[:id], scope)
33
35
  when locator[:name]
34
- Library::find_child_by_name(@element, locator[:name])
36
+ Library::find_child_by_name(@element, locator[:name], scope)
35
37
  end
36
38
  end
37
39
 
data/lib/uia/library.rb CHANGED
@@ -61,8 +61,8 @@ module Uia
61
61
  attach_function :Element_FindByRuntimeId, [:pointer, :int, :pointer, :int], ManagedElementStruct.by_ref
62
62
 
63
63
  # element methods
64
- attach_throwable_function :find_child_by_id, :Element_FindChildById, [:pointer, :string], ManagedElementStruct.by_ref, &element_or_nil
65
- attach_throwable_function :find_child_by_name, :Element_FindChildByName, [:pointer, :string], ManagedElementStruct.by_ref, &element_or_nil
64
+ attach_throwable_function :find_child_by_id, :Element_FindChildById, [:pointer, :string, :string], ManagedElementStruct.by_ref, &element_or_nil
65
+ attach_throwable_function :find_child_by_name, :Element_FindChildByName, [:pointer, :string, :string], ManagedElementStruct.by_ref, &element_or_nil
66
66
  elements_from :children, :Element_Children, [:pointer]
67
67
  elements_from :descendants, :Element_Descendants, [:pointer]
68
68
  attach_throwable_function :click, :Element_Click, [:pointer], :void
data/lib/uia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uia
2
- VERSION = '0.0.7.1'
2
+ VERSION = '0.0.7.2'
3
3
  end
@@ -58,6 +58,10 @@ describe Uia::Element do
58
58
  Then { element.find(name: 'No option selected') != nil }
59
59
  Then { element.find(name: 'does not exist') == nil }
60
60
  end
61
+
62
+ context 'limiting scope' do
63
+ Then { element.find(name: 'label2', scope: :children) == nil }
64
+ end
61
65
  end
62
66
 
63
67
  context '#select' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7.1
4
+ version: 0.0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  segments:
241
241
  - 0
242
- hash: 1001089377
242
+ hash: -527449199
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  none: false
245
245
  requirements:
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  version: '0'
249
249
  segments:
250
250
  - 0
251
- hash: 1001089377
251
+ hash: -527449199
252
252
  requirements: []
253
253
  rubyforge_project:
254
254
  rubygems_version: 1.8.24